I want the code I currently have to go through a list of questions infinitely or until someone gets an answer wrong. I am currently using
random.shuffle(questions)
for question in questions:
question.ask()
to ask every question in a list once.
How do I make it continuously ask until the user inputs a wrong answer? Here is my current code:
class Question(object):
def __init__(self, question, answer):
self.question = question
self.answer = answer
def ask(self):
response = input(self.question)
if response == self.answer:
print "CORRECT"
else:
print "wrong"
questions = [
Question("0", 0),
Question("π/6", 30),
Question("π/3", 60),
Question("π/4", 45),
Question("π/2", 90),
Question("2π/3", 120),
Question("3π/4", 135),
Question("5π/6", 150),
Question("π", 180),
Question("7π/6", 210),
Question("4π/3", 240),
Question("5π/4", 225),
Question("3π/2", 270),
Question("5π/3", 300),
Question("7π/4", 315),
Question("11π/6", 330),
Question("2π",360),
]
Also, if you could tell me how to add one score for every question correct that would be much appreciated. I tried to do this but I already have a piece of the program that deducts 1 from a global score variable every 5 seconds. I would like to continue editing that same variable but it gives errors.