title: Adding +1 to a variable inside a function
body: <p>So basically I have no idea what is wrong with this small piece of code, and it seems like I can't find a way to make it work.</p>
  
  <pre><code>points = 0
  
  def test():
      addpoint = raw_input ("type ""add"" to add a point")
      if addpoint == "add":
          points = points + 1
      else:
          print "asd"
      return;
  test()
  </code></pre>
  
  <p>The error I get is:</p>
  
  <pre><code>UnboundLocalError: local variable 'points' referenced before assignment
  </code></pre>
  
  <p>Note: I can't place the "points = 0" inside the function, because I will repeat it many times, so it would always set the points back to 0 first.
  I am completely stuck, any help would be appreciated!</p>