I try to make this code for my little one to practice simple mathematics and I want to give to the user 3 problems to solve, but the program runs random times of problems. What is it I have done wrong? Thanks
import random
for i in range(3): # number of problems
for n in range(999):
num1 = random.randrange(11)
num2 = random.randrange(11)
if num1<num2:
break
else:
sum = eval(input("how much is {} - {} = ".format(num1,num2)))
if sum == num1 - num2:
print ("Good job!")
break
for x in range(5): #nr of wrong tries
if sum != num1 - num2:
sum = eval(input("Try again {} - {} = ".format(num1,num2)))
else:
print ("Good job!")
break