title: python3 ValueError value
body: <p>I am trying to write a function using <code>python3</code>, with <code>exception handling</code>.
  I thought <code>ValueError</code> is the right tool to check if the value is in given range, as given <a href="https://docs.python.org/3/library/exceptions.html#ValueError" rel="nofollow noreferrer">here in python3 doc</a> which says:</p>
  
  <blockquote>
    <p>function receives an argument that has the right type but an inappropriate value</p>
  </blockquote>
  
  <p>So, in this my tiny snippet, I am expecting to use ValueError to check range(0-1) which is not doing:</p>
  
  <pre><code>while True:
      try:
          imode = int(input("Generate for EOS(0) or S2(1)"))
      except (ValueError):
          print("Mode not recognised! Retry")
          continue
      else:
          break
  print(imode)
  </code></pre>
  
  <p>which yeilds:</p>
  
  <pre><code>Generate for EOS(0) or S2(1)3
  3
  </code></pre>
  
  <p>Sure, I can do the value checking as:</p>
  
  <pre><code>if (imode &lt; 0 or imode &gt; 1):
      print("Mode not recogised. RETRY!")
      continue
  else:
      break
  </code></pre>
  
  <p>but the ValueError seems do do this thing. </p>
  
  <p>There are several question on <code>ValueError</code> here, but none of them checking "inappropriate value, e.g. <a href="https://stackoverflow.com/questions/17165427/python-exception-valueerror-error-handling">this</a>
  I am a novice and python is not my main language.
  Kindly give me some insight.</p>