I'm trying to do something along the following lines in python3:
i = 1337
def g():
print(i)
i = 42
g()
but get the following error
UnboundLocalError: local variable 'i' referenced before assignment
I think I understand what the error message means, but why is it the case? Is there any way to circumvent this?