title: can't return a variable outside the function
body: <p>I am trying to return the output from a function and trying to do a function call in  a<code>for</code> loop and printing the output in same loop. But it is not working:</p>
  
  <pre><code>pagination_urls = ["http://google.com"]
  
  def oss(url):
      data = url
      return data
  
  
  for url in pagination_urls:
      oss(url)
      spider = data
      print spider
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Traceback (most recent call last):
    File "mongo.py", line 10, in &lt;module&gt;
      spider = data
  NameError: name 'data' is not defined
  </code></pre>
  
  <p>How to make this program work?</p>