title: PYTHON Return a list from a recursive function
body: <p>I'm coding a program, a part of the program is that I want to create a list with all the substring from a string, using a recursive function. </p>
  
  <p>However, when I return the list, I get nothing. The variable substringList has None value.</p>
  
  <p>How can I return the list, without losing all the data in it?</p>
  
  <pre><code>def main(string):
      substringList = []
      substringList = substring(string, substringList)
  
  def substring(string, substringList):#Recursive function to create all the
      length = len(string)             #substrings**strong text**
  
      if length == 0:
          return substringList
  
      else:
          substringList.append(string)
          substring(string[1::], substringList)
  
  
  string = "bananas"
  main(string)
  </code></pre>