Possible Duplicate:
Using global variables in a function other than the one that created them
I have the following scriptFrom this code:
COUNT = 0
def increment():
COUNT = COUNT+1COUNT + 1
increment()
print COUNT
I just want to increment global variable COUNT, but this gives meget 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? How can I increment the global variable COUNT from inside the function?