title: Python input validation for both integer and string
body: <p>I'm new in programming and I have an issue when doing the input validation.
  My program requires to input number from 1 to 10 or the letter <code>y</code> but it seems that I cannot do an error handler for this.</p>
  
  <pre><code>def checkingInput():
      while True:
          try:
              a = input()
              if 10 &gt;= a &gt;= 1 or a == 'y':
                  return value
              else:
                  print('Invalid input!')
          except NameError:
              print('Name error!Please try again!')
          except SyntaxError:
              print('Syntax Error!Please try again!')
  </code></pre>