I have a list of many 2-tuples. I would like to split the list into two lists, one list consisting of the first elements of all the tuples in the list, and the other list consisting of the second elements of all the tuples. I wonder how to do that efficiently? Thanks!
For example, I have a list y
:
>>> y = [('ab',1), ('cd', 2), ('ef', 3) ]
>>> type(y)
<type 'list'>
I hope to get two lists ['ab', 'cd', 'ef']
and [1, 2, 3]
.