title: How can Python compare strings with integers?
body: <p>Given the following code:</p>
  
  <pre><code>a = '1'
  if a == 1:
      print 'yes'
  else:
      print 'no'
  </code></pre>
  
  <p>we get output as <code>no</code>.</p>
  
  <p>How is Python comparing a string value to an int here (<code>if a == 1</code>)? In C such a comparison would give an error because this is comparing different types.</p>