I only want the inputs 1000 to 1700. The except block is able to catch the error if the input is not an integer and rerun the try block but not if the input is an integer BUT is not the one I want. How can I rerun the try block until the user enters the correct integers? Thanks in advance!
def gettriptime():
while True:
try:
ch=int(input("""
Trip Times:
1000
1100
1200
1300
1400
1500
1600
1700
Please enter trip time: """))
if (ch==1000) or (ch==1100) or (ch==1200) or (ch==1300) or (ch==1400) or (ch==1500) or (ch==1600):
return ch
else:
print("\nInvalid trip time.")
except ValueError:
print("\nPlease enter a valid option. ")
else:
break
gettriptime()