Why the global variable is not working in the different functions in Python?
<p>I'm beginner in Python. I wrote the code like as below just for practice.. Please look on it</p>

<pre><code>i=1
def wrte():
 global i
 while i&lt;5:
     print "%s .Line..\n" %i
     i+=1

def appnd():
  j=i
  while i in range(i,j+3):
     print "%s .Line..\n" %i
     i+=1

def Main():
   wrte()
   appnd()

Main()
</code></pre>

<p>Output is like as below</p>

<pre><code>  1 .Line..

    2 .Line..

    3 .Line..

    4 .Line..

**Traceback (most recent call last):
  Line 18, in &lt;module&gt;
    Main()
  Line 16, in Main
    appnd()
  Line 9, in appnd
    j=i
UnboundLocalError: local variable 'i' referenced before assignment**
</code></pre>

<p>Expected Result:: The next sequence is should be appended like</p>

<pre><code>5. Line..
6. Line..
7. Line..
</code></pre>

<p>Please help me on this..</p>
