So I wrote this fragment of code inside one of my projects, and defined n to be a boolean value True. Then, I used it to make a toggle case of a pause/resume button. For some reason, I get the error for using n in the if statement before allegedly assigning it inside the if and else code, although I already assigned it above the whole function.
Can somebody explain this error? And maybe suggest a way to fix it?
n = True
def pauseresume():
if n:
pauseb.configure(text="Resume")
n = False
else:
pauseb.configure(text="Pause")
n = True