title: Python 3: UnboundLocalError: local variable referenced before assignment
body: <p>The following code gives the error <code>UnboundLocalError: local variable 'Var1' referenced before assignment</code>:</p>
  <pre><code>Var1 = 1
  Var2 = 0
  def function(): 
      if Var2 == 0 and Var1 &gt; 0:
          print(&quot;Result One&quot;)
      elif Var2 == 1 and Var1 &gt; 0:
          print(&quot;Result Two&quot;)
      elif Var1 &lt; 1:
          print(&quot;Result Three&quot;)
      Var1 =- 1
  function()
  </code></pre>
  <p>How can I fix this?</p>