Reputation: 114
Take this below code as example
import time
for i in range(1,10):
x=int(input("Enter any number: "))
if x!=None:
break
else:
continue
What I need is, if the user didn't respond to the input prompt within 10 seconds, it should go to next statements.
Upvotes: 0
Views: 545
Reputation: 161
You could spawn a separate thread to take input from the user, and in your main program wait 10 seconds and if nothing is returned kill the thread and set x to none.
Upvotes: 1