0

I want to make code which stops the countdown timer when the input entered is either left or right. It's kind of similar to a gameshow where the person has a certain amount of time to answer the question. However when I try entering the input question into the code it disables the timer. What should I do?

import sys,time
def msg(txt):
    sys.stdout.write(txt)
    sys.stdout.flush()

for sec in range(10):
    time.sleep(1)
    m = "%2d" % (10-sec)
    msg(m + chr(13))
print('You have been caught. Game over.')

if x == 'left':
  print('you escaped')
elif x == 'right':
  print('you escaped')
  • There are some [answers to this question](https://stackoverflow.com/q/45419723/2280890) about implementing timers that might help. – import random Sep 14 '22 at 03:19

0 Answers0