forked from Nyasita/HackBioAssignmentPauling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKwabena_Gyampo.py
43 lines (29 loc) · 1.05 KB
/
Kwabena_Gyampo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Name: First and Last
name = 'Kwabena Gyampo'
# Email
email = '[email protected]'
# Slack Username
slack_username = '@Kwabena'
# Biostack
biostack = 'Genomics'
# Twitter Handle
twit_handle = '@_gyampo'
def hamming_distance(slack_handle, twitter_handle):
'''
Returns int counter which is the Hamming Distance of the two(2) strings,
slack and twitter handle.
'''
# Check if slack and twitter handles are strings
if not (isinstance(slack_handle, str) and isinstance(twitter_handle, str)):
raise TypeError('Please enter a string of characters')
if len(slack_handle) != len(twitter_handle):
raise Exception('Hamming distance is only valid for strings of equal length')
counter = 0
for x, y in zip(slack_handle, twitter_handle):
counter += (x!=y)
# one line implementation
# sum(x!=y for x,y in zip(slack_handle,twitter_handle))
return counter
print(f'{name} \n{email} \
\n{slack_username} \n{biostack} \
\n{twit_handle} \n{hamming_distance(slack_username, twit_handle)}')