Related to: Misspelling Type: Find neighbor states function
The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. Put another way, it measures the minimum number of substitutions required to change one string into the other, or the number of errors that transformed one string into the other.

Python code:

def hammingDistance(s,t):
    assert len(s) == len(t)
    return sum([ch1 != ch2 for ch1, ch2 in zip(s,t)])