Conversion of List of Tuples
Chris Kaynor
ckaynor at zindagigames.com
Mon Dec 3 15:10:02 EST 2012
On Mon, Dec 3, 2012 at 11:58 AM, <subhabangalore at gmail.com> 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.
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list