Hamming Distance in Python
That's a reasonable approach, but converting to strings early and then doing everything on strings leads to a lot of extra code. Note that this construct in your code, if x!=y, essentially XORs two bits and then does something if the result of that XOR is 1.

Doing that XOR directly on the integers makes the problem simpler, the whole problem of having to pad with zeroes disappears (which about halves the code size already), and the problem is reduced to "count the ones in binary". That could still be done with a similar loop, but there is a short-cut:

return bin(x ^ y).count('1')