title: flatten list of list through list comprehension
body: <p>I am trying to flatten a list using list comprehension in python. My list is somewhat like </p>
  
  <pre><code>[[1, 2, 3], [4, 5, 6], 7, 8]
  </code></pre>
  
  <p>just for printing then individual item in this list of list I wrote this code</p>
  
  <pre><code>   def flat(listoflist):
       for item in listoflist:
               if type(item) != list:
                       print item
               else:
                       for num in item:
                               print num  
  &gt;&gt;&gt; flat(list1)
  1
  2
  3
  4
  5
  6
  7
  8
  </code></pre>
  
  <p>Then I used the same logic to flatten my list through list comprehension I am getting the following error</p>
  
  <pre><code>    list2 = [item if type(item) != list else num for num in item for item in list1]
      Traceback (most recent call last):
      File "&lt;stdin&gt;", line 1, in &lt;module&gt;
      TypeError: 'int' object is not iterable
  </code></pre>
  
  <p>How can I flatten this type of list-of-list using using list comprehension ? </p>