title: is it possible to create a list of lists on a recursive function?
body: <p>My goal is to build all possible combinations between the keys in a dictionary (plus a few other rules that don't really matter), so I wrote the recursive function bellow.</p>
  
  <pre><code>dict = {3: 54, 37: 100, 56: 33}
  
  def dosomething(dict, indent, stop, position):
      if dict == {} or stop &lt;0:
          return
  
      keys = dict.keys()
      for k in keys:
          if k &gt; position:
              print indent, k
              dosomething(dict, indent + "    ", stop -1, k)
  
  indent = " "
  dosomething(dict, indent, 4, 0)
  </code></pre>
  
  <p>Printing the result show the values I want:</p>
  
  <pre><code> 56
   3
       56
       37
           56
   37
       56
  </code></pre>
  
  <p>but now I'd like to have them in a list of lists where the elements would be:</p>
  
  <pre><code>[56]
  [3,56]
  [3,37,56]
  [37,56]
  </code></pre>
  
  <p>Would anyone be able to help me with that?</p>