Thank you for writing the post. Newbie question about “nonlocal” from your example:
def outer_function():
x = 11
def inner_function():
nonlocal x
x = 22
print('Inner x:', x)
inner_funcion()
print('Outer x:', x)
I get how the example works, but don’t see the point of the declaration? If I just left out the “nonlocal x” line, wouldn’t the example still work the same?