I'm trying to get my program to iterate through a loop after a person gets the correct answers to the first question. I feel like there is a better way to do things syntactically.
math_questions = [
{'question1':'1*1',
'answer1':1,
'quote1' :'What you are,you are by accident of birth; what I am,I am by myself.\n There are and will be a thousand princes; there is only one Beethoven.'},
{'question2':'2*1',
'answer2':2,
'quote2': 'Two is company, three is a crowd'},
{'question3': '3*1',
'answer3': 3,
'quote3': 'There are three types of people, those who can count and those who cannot'}
]
# read from a txt file later???
for question in math_questions:
print math_questions[0]['question1']
math_answer = int(raw_input("What is the answer to " + math_questions[0]["question1"] +"? : "))
if math_answer == math_questions[0]['answer1']:
print math_questions[0]['quote1']
else:
print "Try again"
print math_questions[0]['answer1']
math_questions[0]
. This code does not ask three quesitions, but one question three times. – rolfl♦ Jun 1 at 4:32