I have tried to make my scoring system for my quiz work for days now with no avail. I have tried 'global', +=, score = score + 1, and so on and I am always getting pretty much the same error. "Local Variable "score" referenced before assignment", however I have put 'score = 0' at the top, also noting that the question is in a 'def' function. I tried some tests in a separate document and when I remove the function from the code, it seemed to add / subtract points fine. I would like to have functions within my code to be able to return to the beginning of the question when a incorrect answer is inputted. Thanks.
Whole Code: https://repl.it/@oliverpurchase/test2
import time
score = 0
def question1():
question_1 = input("1.\n2.\n3.\n4.\n")
if question_1 == "3":
time.sleep(0.5)
print("Correct!")
score += 1
print ("Your now have a score of ",s,"!")
else:
print("Incorrect..")
time.sleep(0.5)
score -= 1
print ("Your now have a score of ",s,"!")
time.sleep(0.5)
print("Try Again")
time.sleep(0.5)
return question1()
question1()