def hamming(str1, str2):
    dist = 0
    last_longer = len(str1) < len(str2)
    first, last = (str1, str2,) if last_longer else (str2, str1,)
    for k, letter in enumerate(str1):
        try:
            if str1[k] != str2[k]:
                dist += 1
        except IndexError:
            continue
    # Add remainder between offset of each (e.g. "cat", "cats" = range(2, 3))
    for k in range(len(first), len(last)):
        dist += 1
    print('Hamming dist for `{}` and `{}` = {}'.format(str1, str2, dist))
    return dist
Algorithm based on an old project of mine, ported from yavascript:
dataset/ETHPy150Open christabor/MoAL/MOAL/algorithms/coding_theory/hamming_distance.py/hamming