title: Getting a double output of last input after a validation check in a while loop
body: <p>I'm learning input validation in a while loop. If i enter 1, 2, 3, x, -1 as my inputs it prints 1, 2, 3, 3. Can someone explain why it outputs the 3 twice. Is my try statement incorrect or in the wrong spot?</p>
  
  <pre><code>def input_validation_while_loop():
  
      list = []
  
      guess_num = int(input("Enter a number between 1 and 100 or enter -1 to stop."))
  
      # sentinel_value = -1
      while guess_num != -1:
          try:
              if 1 &lt;= guess_num &lt;= 100:
                  list.append(guess_num)
              guess_num = int(input("Enter a number between 1 and 100 or enter -1 to stop."))
          except ValueError:
              print("That was not a number. Try again.")
  
      else:
          for x in list:
              print(x)
  </code></pre>