From this code:
COUNT = 0
def increment():
COUNT = COUNT + 1
increment()
I get 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? How can I increment the global variable COUNT
from inside the function?