Guest User

Untitled

a guest
Nov 14th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. def hamming_distance(s1, s2):
  2. if len(s1) != len(s2):
  3. print("Strings must be of equal length")
  4. return -1
  5.  
  6. count = 0
  7. strings_to_compare = list(zip(s1, s2))
  8.  
  9. for i in range(len(strings_to_compare)):
  10. for j in range(i, i + 1):
  11. if strings_to_compare[i][0] != strings_to_compare[j][1]:
  12. count += 1
  13.  
  14. return count
Add Comment
Please, Sign In to add comment