Oct-16-2020, 06:26 PM
(This post was last modified: Oct-16-2020, 09:14 PM by deanhystad.)
As Griboullis mentioned you are not comparing ints, you are comparing strings. When comparing strings '0' > '9' and '123456' < '2'. So your code works as long as you limit yourself to single digit numbers in the range 1 through 9. If you want to compare numbers you need to convert to a number. I would surround the conversion with try/except to prevent exiting the program if the user types something that isn't a number
It is odd defining a function inside of an if statement. It is valid Python, but really odd. It is also odd using recursion for something like this when a loop is simpler. I would write the code like this:
It is odd defining a function inside of an if statement. It is valid Python, but really odd. It is also odd using recursion for something like this when a loop is simpler. I would write the code like this:
elif time_limit_ask[0] in ('r', 'R'): while True: try: if int(input("enter number ")) > int(input("enter number ")): break except ValueError: pass intro_1_complete = True time_limit_exists = True