title: Why Increment Statement in python 3 not working?
body: <h1><strong>I wrote a simple script which increments a integer, but it is not working and i got an error.</strong></h1>
  
  <p>my script :</p>
  
  <pre><code>x = 1
  def inc():
      x +=1
      print(x)
  
  if __name__ == "__main__""" :
      inc()
  </code></pre>
  
  <p>when i run this script i got this : </p>
  
  <pre><code>palash@ash:~/PycharmProjects/src$ python tt.py
  Traceback (most recent call last):
    File "tt.py", line 7, in &lt;module&gt;
      inc()
    File "tt.py", line 3, in inc
      x +=1
  UnboundLocalError: local variable 'x' referenced before assignment
  palash@ash:~/PycharmProjects/src$
  </code></pre>
  
  <h3>my python version : <code>Python 3.6.1 :: Anaconda custom (32-bit)</code></h3>
  
  <h3>and I'm running on Ubuntu 17.04 32bit</h3>
  
  <p>I can't understand what is happening. Help me please</p>
  
  <p>Edit:
  And can anybody define what is UnboundLocalError?</p>
  
  <p>And Why  <code>"__main__"""</code>is working ?</p>