I have a list of nested tuples as
[(('p1', 'p2'), ('m1',)), (('p2', 'p1'), ('m1',))]
How can i convert it into list of tuples as
[('p1', 'p2', 'm1'), ('p2', 'p1', 'm1')]
without using for loop
You can do with itertools.chain
,
In [91]: from itertools import chain
In [92]: [tuple(chain(*item)) for item in a]
Out[92]: [('p1', 'p2', 'm1'), ('p2', 'p1', 'm1')]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments