title: How to return a list of all possible numbers using recursion
body: <p>I am learning about recursion in python currently but there is this one exercise that I simply cannot figure out in the following code I have two functions and using recursion i print all possible numbers from a given list, but for the life of me I cannot get all the possible numbers into a single list. Any tips on how to do this would really be appreciated.</p>
  <pre><code>def find_possible_strings(char_set, n):
      k = len(char_set)
      return possible_stringsRec(char_set, &quot;&quot;, k, n)
  
  
  def possible_stringsRec(char_set, prefix, k, n):
      if n == 0:
          print(prefix)
          return
  
      for i in range(k):
          newPrefix = prefix + char_set[i]
          possible_stringsRec(char_set, newPrefix, k, n - 1)
  
  char_set = ['a','b']
  possible_strings = find_possible_strings(char_set, 2)
  print(possible_strings) 
  </code></pre>
  <p>Just to specify I am not simply looking for a solution but rather an actual explanation of how this could be done in python if anyone would be so kind.</p>
  <p>I am just getting the result as follows:</p>
  <pre><code>aa
  ab
  ba
  bb
  None
  </code></pre>
  <p>and what I want is for all those values to be stored inside a single list
  so essentially:</p>
  <pre><code>['aa', 'ab', 'ba', 'bb'] 
  </code></pre>