Reputation: 2221
I have this:
t=[(1,2,3),(4,5,6),(11,22,33),(44,55,66)]
and want to get this :
[(1,4,11,44),(2,5,22,55),(3,6,33,66)]
How to do it in a pythonic way.
Upvotes: 3
Views: 4757
Reputation: 1702
Use star(*). It can unpacking argument lists.
>>> zip(*t)
[(1, 4, 11, 44), (2, 5, 22, 55), (3, 6, 33, 66)]
For example:
>>> args = [3, 6]
>>> range(*args) # It's equivalent to range(3, 6)
[3, 4, 5]
Upvotes: 6