Can not increment global variable from function in python
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them">Using global variables in a function other than the one that created them</a>  </p>
</blockquote>



<p>Hello Guys! I have the following script:</p>

<pre><code>COUNT = 0

def increment():
    COUNT = COUNT+1

increment()

print COUNT
</code></pre>

<p>I just want to increment global variable COUNT, but this gives me the following error:</p>

<pre><code>Traceback (most recent call last):
  File "test.py", line 6, in &lt;module&gt;
    increment()
  File "test.py", line 4, in increment
    COUNT = COUNT+1
UnboundLocalError: local variable 'COUNT' referenced before assignment
</code></pre>

<p>Can anyone explain me why it is so?</p>
