title: Python XOR hammingDistance
body: <hr />
  <p>The problem is</p>
  <blockquote>
  <p>Given two integers x and y, calculate the Hamming distance.</p>
  <p>Note:
  0 ≤ x, y &lt; 231.</p>
  </blockquote>
  <p>I tried to use the ^ operator and just count the number of 1s in the resulting str. However it did not pass all the testing cases. For instance. 93^73 returns <code>11188</code> when it's supposed to return something else.</p>
  <p>Here is my code:</p>
  <pre><code>#hamming distance
  class Solution(object):
      def hammingDistance(x, y):
          &quot;&quot;&quot;
          :type x: int
          :type y: int
          :rtype: int
          &quot;&quot;&quot;
          bin_x=int(bin(x)[2:])
      bin_y=int(bin(y)[2:])
      print(bin_x)
      print(bin_y)
      print(str(bin_x^bin_y))
      #.count('1'))
      hammingDistance(93,73)
  </code></pre>