How to flatten a list of tuples into a pythonic list
Question: Given the following list of tuples:

    
    
    INPUT = [(1,2),(1,),(1,2,3)]
    

How would I flatten it into a list?

    
    
    OUTPUT ==> [1,2,1,1,2,3]
    

Is there a one-liner to do the above?

Similar: [Flatten list of Tuples in
Python](http://stackoverflow.com/questions/15994124/flatten-list-of-tuples-in-
python)


Answer: You could use a [list
comprehension](https://docs.python.org/3/tutorial/datastructures.html#list-
comprehensions):

    
    
    >>> INPUT = [(1,2),(1,),(1,2,3)]
    >>> [y for x in INPUT for y in x]
    [1, 2, 1, 1, 2, 3]
    >>>
    

[`itertools.chain.from_iterable`](https://docs.python.org/3/library/itertools.html#itertools.chain.from_iterable)
is also used a lot in cases like this:

    
    
    >>> from itertools import chain
    >>> INPUT = [(1,2),(1,),(1,2,3)]
    >>> list(chain.from_iterable(INPUT))
    [1, 2, 1, 1, 2, 3]
    >>>
    

That's not exactly a one-liner though.

