Python Zip Single List Element
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.
Solution 1:
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]
Post a Comment for "Python Zip Single List Element"