Asking a user for input only for a limited amount of time in python [duplicate]
问题 This question already has answers here : Keyboard input with timeout? (11 answers) Closed 4 years ago . The program I am working on needs to pause and ask the user for input and if there is none, move on with the program. I think it would look something like this: import time ...[code to run before break]... if input in time.sleep(5): [break out of normal code] else: [return to normal code] [code to run after break]... Any thoughts? EDIT: Didn't think about this when I asked but I am running