Reputation: 21
I have been writing a simple quiz with python but keep getting a "SyntaxError: multiple statements found while compiling a single statement" in my Python GUI. Please help.
print("Welcome to my quiz!")
score = 0
question1 = str(input("What colour is a banana."))
if question.lower() == 'yellow':
print("Correct. The answer is", question1)
score = score + 1
else:
print("Incorrect. The answer is yellow, not", question1)
print score
Upvotes: 2
Views: 254
Reputation:
This is a more advanced version of your program but by using a list we can do it easier
print("Welcome to my quiz!")
score = 0
color = ['yellow']
question1 = str(input("What colour is a banana."))
if question1 == color[0]:
print("Correct. The answer is", question1)
score +=1
print(score)
else:
print("Incorrect. The answer is yellow, not", question1)
print (score)
Upvotes: 0
Reputation: 17168
You've got a couple issues. First, question
is not defined (line 4); that should be question1
. Second, print
is a function in Python 3, so your last line ought to be print(score)
. Third, input
already returns a string, so you don't need the str
call. So line 3 ought to look like this:
question1 = input("What colour is a banana.")
Upvotes: 8