in Python, How to join a list of tuples into one list?

python, tuples

Solution

b = [i for sub in a for i in sub]

That will do the trick.

Problem

Following on my previous question How to group list items into tuple? If I have a list of tuples, for example ``` a = [(1,3),(5,4)] ``` How can I unpack the tuples and reformat it into one single list ``` b = [1,3,5,4] ``` I think this also has to do with the `iter` function, but I really don't know how to do this. Please enlighten me.

Original source

Related problems