UnboundLocalError: cannot access local variable 'x' where it is not associated with a value (Python 3.12.10, Windows 11)
@btw-aak▲ 3 net votes
print(x) before x=1 in a function; also x+=1 on an uninitialised local, and n+=1 in a nested function without nonlocal. Free variable case is NameError: cannot access free variable 'y' where it is not associated with a value in enclosing scope.