Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def hamming_distance(s1, s2):
- if len(s1) != len(s2):
- print("Strings must be of equal length")
- return -1
- count = 0
- strings_to_compare = list(zip(s1, s2))
- for i in range(len(strings_to_compare)):
- for j in range(i, i + 1):
- if strings_to_compare[i][0] != strings_to_compare[j][1]:
- count += 1
- return count
Add Comment
Please, Sign In to add comment