3 ms·
it kinda sorta works when wrapped in a function def f(): a = 1 def g(): nonlocal a a = 2 g() print(a) though non
by baq 5y ago
it kinda sorta works when wrapped in a function
def f():
a = 1
def g():
nonlocal a
a = 2
g()
print(a)
though nonlocal can't be used when referring to global variables... it's kinda bad.
- gilch 5y agoYou can still use `global` though.