title: How to restrict user input to a range of integers - python 3.6
body: <p>I am trying to figure this out on my assignment, but I am struggling sooo hard.</p>
  
  <p>So what I need is restricting the user input for variable 'age' to be equal to or greater than 18. I want to display my own error message and terminate the program if the input is either string or less than 18.</p>
  
  <p>Also I have noticed that the program is automatically showing ValueError when letters are inputted because I have used the int() for my input. But I would like to change that error message to my own. I read somewhere to call and check the values first then int() them, so I tried the input() by itself but don't think it worked either.</p>
  
  <p>Here is what I have now for the age portion:</p>
  
  <pre><code>age = int(input('Enter age'))
  if not age.isdigit():
      sys.stderr.write('Please enter appropriate age')
      sys.exit(1)
  elif age &lt; 18:
      print('You have to be at least 18 years old')
      sys.exit(1)
  else:
      age = int(age)
  </code></pre>
  
  <p>I tried to do something like set the conditions for it to quit, then for other conditions it would keep going.......... but I am not sure if else could go with if not and I don't think it worked :(</p>
  
  <p>Any help is appreciated!! </p>