title: Python check for integer input
body: <p>I am trying to allow a user to input into my program, however when they enter a string my program fails. It is for a bigger program but was trying to correct the problem, I have so far:</p>
  
  <pre><code>data = raw_input('Enter a number: ')
  number = eval(data)
  if type(number) != int:
       print"I am afraid",number,"is not a number"
  elif type(number) == int:
      if data &gt; 0:
          print "The",number,"is a good number"
      else:
          print "Please enter a positive integer"
  </code></pre>
  
  <p>when the user enters a string, it returns:</p>
  
  <pre><code>number = eval(data)
    File "&lt;string&gt;", line 1, in &lt;module&gt;
  NameError: name 'hel' is not defined
  </code></pre>
  
  <p>Any help would be most appreciated.</p>