I'm programming a function that requests the user for input, and I would like the function to automatically terminate if the user takes too long to enter the input.
For example, a simplified version of my code is of the following:
user_input = input('Please enter "yes" or "no" below: ')
if user_input.lower() == 'yes':
# executes some code
elif user_input.lower() == 'no':
# executes some code
else:
# executes some code
Right now the program will wait for the user to input the result before executing anything else and as stated above, I would like the program to automatically stop running if the user takes too long to input the answer.
I'd appreciate any help!