Conversion of List of Tuples

Chris Kaynor ckaynor at
Mon Dec 3 21:10:02 CET 2012

On Mon, Dec 3, 2012 at 11:58 AM,  <subhabangalore at> wrote:
> Dear Group,
> I have a tuple of list as,
> tup_list=[(1,2), (3,4)]
> Now if I want to covert as a simple list,
> list=[1,2,3,4]
> how may I do that?
> If any one can kindly suggest? Googling didn't help much.

If you know they are always exactly two levels deep, you can use
nested loops (in comprehension form):
[item for tuple_ in list_ for item in tuple_]

That could also be written how John recommended, in three lines.

> Regards,
> Subhabrata.
> --

More information about the Python-list mailing list