I am trying to make a random number game but I have hit a wall. I do not understand why I am getting a Invalid syntax error on line 11. Any help would be great.
import random
ops = ['+', '-', '*', '/']
x = 0
score = 0
while x <= 10:
num1 = random.randint(1,10)
num2 = random.randint(1,10)
operation = random.choice(ops)
maths = int(eval(str(num1) + operation + str(num2)))
answer = int(input("What is the answer to that arithmetic question?")
if answer == maths:
print ("Correct, You scored a point")
score = score + 1
else:
print ("No points scored, Incorrect Answer")
print(num1,operation,num2, "=", maths)
x = x + 1
Cheers.
Aucun commentaire:
Enregistrer un commentaire