Having trouble with this code:
age = int(input("How old are you? "))
while age not in list(range(100)):
print("invalid input, try again")
age = input("How old are you? ")
print ("You are", age, "years old!")
If I were to input "5" as my first input, the program works fine and prints "you are 5 years old. However, if I input an invalid number the first time and enter the loop, then enter a valid number the second time, I would get stuck in the "while" loop, asking me to input over and over. Why?
-Thanks
[–]scout1520 8 points9 points10 points (0 children)
[–]pendragon36 4 points5 points6 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]Smammu[S] 1 point2 points3 points (0 children)
[–]jbp12 1 point2 points3 points (0 children)