title: How can i define a shared list in the recursive function in python?
body: <p>I want to encapsulate my function and define the list in the function, not before it!
  for example in this code:</p>
  <pre><code>s = []
  def rec(n):
      if n == 0:
          return s
      else:
          s.append(n)
          rec(n-1)
          return s
  print(rec(5))
  </code></pre>
  <p>but when i define it in the recursive function, it become local.</p>