def hamming_distance(str1, str2):
    """calculate the hamming distance of two strings."""
    # ensure length of str1 >= str2
    if len(str2) > len(str1):
        str1, str2 = str2, str1
    # distance is difference in length + differing chars
    distance = len(str1) - len(str2)
    for index, value in enumerate(str2):
        if value != str1[index]:
            distance += 1

    return distance