I'm looking for a way to have python stop a user input from happening if it's not done in enough time. The code contains a timer which currently does countdown properly but it waits for user input to check any if statements made. I need it to end the while loop if the user input isn't made within 15 seconds which will in-turn display the user losing.
def timer(tim):
    time.sleep(1)
def hall():
    print("Where will you go?")
    tim = 15
    while(tim > 0):
        direction = input()
        if(direction == "left"):
            print("you went left")
        if(direction == "right"):
            print("you went right")
        if(direction == "forward"):
            print("you went forward")
        timer(tim)
        tim-=1
        break
    print ("you took to long, you lose")
Every solution I was pointed to is for a different version of python and uses raw_input which is not in Python 3.
