KrisH Jodu
KrisH Jodu

Reputation: 114

How to skip the input statement if user not responded to it in python3?

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

Answers (1)

GustavD
GustavD

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

Related Questions