Multi-threading with a simple timer?
David D
daviddschool at gmail.com
Tue Jul 3 12:44:25 EDT 2018
This works, but does not do exactly what I want. What I want to happen is : when the user enters in a correct answer, the program and threading stops. Any ideas on what I should change?
import time
from threading import Thread
class Answer(Thread):
def run(self):
a=input("What is your answer:")
if a=="yes":
print("yes you got it")
finished()
else:
print("no")
class myTimer(Thread):
def run(self):
print()
for x in range(5):
time.sleep(1)
Answer().start()
myTimer().start()
print("you lost")
def finished():
print("done")
More information about the Python-list
mailing list