Possible Duplicate:
Using global variables in a function other than the one that created them
I have the following script:
COUNT = 0
def increment():
COUNT = COUNT+1
increment()
print COUNT
I just want to increment global variable COUNT, but this gives me the following error:
Traceback (most recent call last):
File "test.py", line 6, in <module>
increment()
File "test.py", line 4, in increment
COUNT = COUNT+1
UnboundLocalError: local variable 'COUNT' referenced before assignment
Why is it so?