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 elem
Your could use the following function and apply it in a loop to every element in the list.
import type
def flatten(T):
if type(T) != types.TupleType: return (T,)
elif len(T) == 0: return ()
else: return flatten(T[0]) + flatten(T[1:])
How it works:
The nice thing in this solution is:
The code is slightly adapted from following source:
https://mail.python.org/pipermail/tutor/2001-April/005025.html
Hope it helps someone :)