title: How to recursively add items to a list?
body: <p>Currently, I'm working on a problem. I am given a list, whose elements may contain other lists, lists of lists, or integers. For example, I may receive:</p>
  
  <pre><code>[[[[], 1, []], 2, [[], 3, []]], 4, [[[], 5, []], 6, [[], 7, [[], 9, []]]]]
  </code></pre>
  
  <p>My goal is to parse the array, and append <em>only the integers</em> to a new list. Here is what I have done so far:</p>
  
  <pre><code>def fun(a):
      if a == []:
          return None
      elif type(a) == int:
          print("Found a digit: ", a)
          return a
      for i in a:
          fun(i)
  </code></pre>
  
  <p>Currently, this function recursively goes through the list and successfully finds each integer; now, I am having an issue with <em>appending</em> those integers to a new list, and returning that list at the very end. The output should be like this:</p>
  
  <pre><code>[1,2,3,4,5,6,7,9]
  </code></pre>
  
  <p>Any pointers?</p>