title: Finding perfect square
body: <p>I have this python code:</p>
  
  <pre><code>def sqrt(x):
      ans = 0
      if x &gt;= 0:
          while ans*ans &lt; x:
              ans = ans + 1
              if ans*ans != x:
                  print x, 'is not a perfect square.'
                  return None
              else:
                  print x, ' is a perfect square.'
                  return ans
      else:
          print x, ' is not a positive number.'
          return None
  
  y = 16      
  sqrt(y)
  </code></pre>
  
  <p>the output is:</p>
  
  <pre><code>16 is not a perfect square.
  </code></pre>
  
  <p>Whereas this works perfectly:</p>
  
  <pre><code>x = 16
  ans = 0
  if x &gt;= 0:
      while ans*ans &lt; x:
          ans = ans + 1
          #print 'ans =', ans
      if ans*ans != x:
          print x, 'is not a perfect square'  
      else: print ans, 'is a perfect square'
  else: print x, 'is not a positive number'
  </code></pre>
  
  <p>What am I doing wrong? </p>