Python Hamming distance exercise