Unable to modify a global int, but can modify a list. How?
<pre><code>&gt;&gt;&gt; LISTL = []
&gt;&gt;&gt; VAR1 = 0
&gt;&gt;&gt; def foo():
...     VAR1 += 1
...     return VAR1
... 
</code></pre>

<p>On calling <code>foo()</code>, I get this error:</p>

<pre><code>UnboundLocalError: local variable 'VAR1' referenced before assignment
</code></pre>

<p>However, consider the list <code>LISTL</code></p>

<pre><code>&gt;&gt;&gt; def foo(x):
...     LISTL.append(x)
...     return LISTL
... 
&gt;&gt;&gt; foo(5)
[5]
</code></pre>

<p>This works as expected. The question is why the append on a list works but I can't change the int?</p>

<p>Also, is this the right way to declare a global in Python? (Right after the import statements)</p>
