import random # generate problem num1 = random.randint(0,9) num2 = random.randint(0,9) # enter into an infinite loop while True: # ask the user to answer a math question answer = int(input("What is " + str(num1) + " plus " + str(num2) + " ? ")) # did they get it right? if answer == num1+num2: # congratulate the user print ("Correct!") # end the loop break # did they get it wrong? else: print ("Incorrect, try again")