#Quiz answer variables go here!
ca1 = cringe_crew[0]
ca2 = cucks[0]
ca3 = 5
ca4 = cringe_crew[1]
ca5 = 'No'
#Questions
q1 = "Question 1 - Who do we refer to when shouting CODE YELLOW? "
q2 = "Question 2 - Who would you think of if I called him 'Linux Boy': "
q3 = "Question 3 - How many people were there in the original Cringe-Crew back in the days of 2015? "
q4 = "Question 4 - Biggest pseudo Overwatch fan? (top tip: even bought a bag): "
q5 = "Question 5 - Do we miss Luke Slater? "
#a is the raw_input answer
#b is the correct answer needed
#a1-a5 will be separately stored raw_input ANSWERS
#ca1-ca5 are already called as variables and these are the correct answers.
#Score
score = 0
def compare( a, ca ):
if a == ca:
score = score + 1
print "That's correct! The answer was %s" % ca
print "Your score is", score
else:
print "%s is not the correct answer - you did not get a point!" % a
return;
#test
a1 = raw_input(q1)
compare( a1, ca1 )
a2 = raw_input(q2)
compare( a2, ca2 )
a3 = raw_input(q3)
compare( a3, ca3 )
a4 = raw_input(q4)
compare( a4, ca4 )
a5 = raw_input(q5)
compare( a5, ca5 )
Hey guys, I am completely new to python and coding overall, but wanted to kick off with a little quiz with a score, although I feel like I went off doing it completely wrong structure-wise, if i remove the 'scores' the code runs completely fine. If I have it, this happens:
Traceback (most recent call last):
File "ex2.py", line 57, in <module>
compare( a1, ca1 )
File "ex2.py", line 46, in compare
score = score + 1
UnboundLocalError: local variable 'score' referenced before assignment
Can you give me any tips especially on how to structure the code in such case? Many thanks!