I am trying to make a timer (Python 3.6.0). I know there are other posts with simpler timers but I want to make a more complex timer. Here is my code:
import time
x = 0
run = input("Start timer? [Y]/[N]")
while run == 'Y':
time.sleep(1)
x += 1
print(x)
else:
print("end of code")
Is there a way to break the while loop (so that the timer can stop) while the program runs? If I put "in = input()" under the "x += 1" line so that the user can stop the loop, the timer stops counting because the user must provide input every second. If I run the above code without any kind of input I cannot type anything in the Python Shell because the loop keeps going. Is there any way to solve this problem?
selectto wait for user input instead of sleeping like in this answer here