I want the python program to wait for user specific char input, let's say "r"/"f", and to continue according to this char.
If after n hours none of these were input, I want the program to do something else. How can this be reached?
I want the python program to wait for user specific char input, let's say "r"/"f", and to continue according to this char.
If after n hours none of these were input, I want the program to do something else. How can this be reached?
Just use this
from threading import Timer
timeout = 10 #here is the time in second
t = Timer(timeout, print, ['Sorry, times up'])
t.start()
prompt = "You have %d seconds to choose the correct answer...\n" % timeout
answer = input(prompt)
t.cancel()