lundi 19 octobre 2015

What's wrong with my code? Invalid syntax

I am making a maths quiz that asks 10 questions that are randomly generated. I am getting an invalid syntax error but can not debug? This is for my Computer Science class so I would be grateful if anyone could help! Traceback error: File "python", line 19 answer = int(input("What is"question"?")) ^ SyntaxError: invalid syntax

import random

score = 0
questions = 0
name = (input("What is your name?"))

print ("Welcome",name,"to this test.")
print ("You will be asked 10 randomly generated questions, you must answer them")

while questions < 10:
    num1 = random.randint(1,10)
    num2 = random.randint(1,10)
    operators = ['+','-','*','/','**']
    operator = random.choice(operators)

    question = eval(str(num1)+operator+(str(num2))


    answer = int(input("What is"question"?"))

    if answer == question:
        score += 1
        print ("Well done",name,"you got the answer correct")

    else:
        print (name, "you got the answer incorrect")

    questions += 1
break




Aucun commentaire:

Enregistrer un commentaire