+ 1
threads? you mean Thread? if yes i will explain it
from threading import Thread
import time
import sys
a = None
def get():
global a
a = input("press Y now! ")
def timer():
time.sleep(2)
if a != 'Y'.lower():
print("\ntoo slow\n")
sys.exit()
c = Thread(target = get, args = [])
d = Thread(target = timer(), args = [])
c.start()
d.start()
that code will getting input user only for 2 seconds.
Thread will let you to run multiple functions at a time.
like you see, variable d and c will run at once.
just make google search first before you ask here. you can ask something here that difficult to ask in google