Time-Limited Input?

input, python, python-3.x, python-multithreading, timer

Solution

Interesting problem, this seems to work:

import time
from threading import Thread

answer = None

def check():
    time.sleep(2)
    if answer != None:
        return
    print("Too Slow")

Thread(target = check).start()

answer = input("Input something: ")

Problem

What I would like to be able to do is ask a user a question using input. For example: ``` print('some scenario') prompt = input("You have 10 seconds to choose the correct answer...\n") ``` and then if the time elapses print something like ``` print('Sorry, times up.') ``` Any help pointing me in the right direction would be greatly appreciated.

Original source

Related problems