title: How to flatten a 2 deep list, return a list without any sublists within
body: <p>I was working on an algorithm that 'flattens' a list, essentially removing any sublists within a list. </p>
  
  <p>For example, [2, 3, [3, 4]] should become [2, 3, 3, 4]. I wrote the following to do this:</p>
  
  <pre><code>def flatten(l):
      total = []
      for i in l:
         if i == int:
             total.append(i)
         elif i == list:
             for j in i:
                 total.append(j):
      return total
  </code></pre>
  
  <p>This algorithm yields an error, however. If someone could help that would be great. Also, if someone could show a recursive path to solve this problem so that lists of arbitrary 'depth' can be flattened (my current algorithm can only flatten a 2D array) </p>