title: How to retain value in recursion
body: <pre><code>def numb_fact(number): 
      factor_list = []
      for d in range(2, number+1, 1):
          if number % d == 0:
              factor_list.append(d)
          else:
              pass
      return factor_list
  def factorize(number):
  
      allfact_list = numb_fact(number)
      final_list = []
      if len(allfact_list) &gt; 0:
          d = allfact_list[0]
          if number % d == 0:
              final_list.append(d)
              divided_numb = int(number / d)
              factorize(divided_numb)
          else:
              if len(allfact_list) &gt; 1:
                  allfact_list.remove(d)
              else:
                  return final_list
          print(final_list)
      return final_list
  
  factorize(12)
  
  Sample output
  [3]
  [2]
  [2]
  </code></pre>
  
  <p>So I'm writing a code to displays a number in multiples of prime numbers. In order to do so, I wanted to start off from making a function that gives me 'list of numbers' that if all the numbers in list were multiplied together, it would form original number.</p>
  
  <p>I thought the only way to write this was recursion, leaving my efficiency of code aside for now - because I know it looks terrible) - this function that I wrote does not retain values in factor_list.
  (well obviously! since I'm restarting the code, and its initially defined as '= []')
  So I've been wondering for hours if there is a way to work this out in a single function.</p>