How to flatten a tuple in python

olliepower picture olliepower · Aug 29, 2013 · Viewed 19.5k times · Source

I have the following element of a list, and the list is 100 elements long.

[(50, (2.7387451803816479e-13, 219))]

How do I convert each element to look like this?

[(50, 2.7387451803816479e-13, 219)]

Answer

user2357112 supports Monica picture user2357112 supports Monica · Aug 29, 2013
[(a, b, c) for a, (b, c) in l]

Tuple packing and unpacking solves the problem.