I know it is a basic question but i don't know reason of this question. I am confused a bit, why global variable is act as local variable in test
method.
x=1
def test():
print x
x=2
print x
print x
test()
print x
It is giving the exception which is like this.
UnboundLocalError: local variable 'x' referenced before assignment
Anyone let me know why it is giving this error.
Thanks