class Game(object):
score = 0
def easyq(self): #Loop
while mode.lower() == "easy":
#Addition
f1 = randint(1,15)
f2 = randint(1,15)
print "What is %r + %r?" % (f1, f2)
answerIn = '%s' % (f1 + f2)
answer = raw_input("> ")
foundit = False
for letter in lettersL:
if letter in answer: foundit = True
for letter in lettersU:
if letter in answer: foundit = True
for symbol in symbols:
if symbol in answer: foundit = True
if answer == "exit":
print "Goodbye!"
time.sleep(2)
exit(0)
elif answer == "pass":
print "Question Passed!"
elif foundit == True:
print "Numbers Only! Question Passed!"
elif answer == answerIn:
score += 1
print "Correct! Your Score: %d" % score
else:
print "Wrong!"
Here's the error:
Traceback (most recent call last):
File "ex45.py", line 278, in <module>
new_game.easyq()
File "ex45.py", line 64, in easyq
score += 1
UnboundLocalError: local variable 'score' referenced before assignment
Any help is greatly appreciated and sorry for the constant need of help! (I'm really struggling)

New Topic/Question
Reply



MultiQuote




|