In python, I need the input of a user to be between a range of years.
Using if statement returns the error (if he's out of range) to the user and invite him to make another choice of year.
The second time he chooses a year need to be tested again with the same conditions. Which doesn't happen yet.
What would be the best solution to have his input tested all over again, until conditions are met ?
Here's some piece of the actual code
year = input("Enter a year between 1900 and 2099 : ")
if year >= "1900" or year <= "2099":
year = (input("The year you entered is out of range, please try again : "))
year = int(year)
Thanks in advance
year >= "1900"? This will do a string lexicographical comparison, as opposed to comparing if the year is less than 1900. For example,'a' >= '1900'evaluates toTruebecauseahas a larger ASCII value than1. Also,'19000' >= '1900' or '19000' <= '2099'will also evaluate toTrue.