Hello @NuclearPasta0
Sorry it seems that when i moved it to my āarchiveā the error occurs there.
the error is that when i have already stated the score beforehand, it says that i have not defined score.
the link is https://replit.com/@creaternet101/Game-Archive/
the modoule is in folder āusedā and is called ballonpopper.py
Thank you.
Hello,
the reason you are getting this error is because score is no longer a global variable, since it is inside the ballongame function now.
To fix, replace all global keywords with nonlocal. The nonlocal keyword is basically like the global keyword, except it is for variables in the enclosing function scope, instead of the module scope.
nonlocal is the same as global except nonlocal only works on the local variables of the āenclosingā function (so the keyword can only be used inside a nested function), and global only works on the top-level, module variables (and this would be used inside any function).
foo = 2
bar = []
def my_function():
eggs = 'hi'
global foo
foo = 5
def my_nested_function():
nonlocal eggs
eggs = 'hello'
global bar
bar = {}