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
An improvement from @sagacity answer, this will rerun a generator that flattens the tuple using a recursive and yield.
def flatten_tuple(inp):
for inp2 in inp:
if not isinstance(inp2,tuple):
yield inp2
elif len(inp2) == 0:
continue
else:
yield from flatten_tuple(inp2)
To make it into list or tuple, use list() or tuple().
list(flatten_tuple(nested_tuple))
tuple(flatten_tuple(nested_tuple))