title: How to flatten a list to return a new list with all the elements?
body: <p>I am trying to write a function called flatten_list that takes as input a list which may be nested, and returns a non-nested list with all the elements of the input list.</p>
  
  <p>My code:</p>
  
  <pre><code>def flatten_list(alist):
      """
      &gt;&gt;&gt; flatten_list([1,2,3])
      [1, 2, 3]
      &gt;&gt;&gt; flatten_list([1, [2,3], [4, 5], 6])
      [1, 2, 3, 4, 5, 6]
      """
      flat_list = []
      for element in alist:
          flat_list += element
      return flat_list
  </code></pre>
  
  <p>This code works for lists with strings, but not integer values. How can I change the code so that it works for both?</p>
  
  <p>thanks</p>