Python 2:
>>> theArray = [['a','b','c'],['d','e','f'],['g','h','i']]
>>> zip(*theArray)
[('a', 'd', 'g'), ('b', 'e', 'h'), ('c', 'f', 'i')]
Python 3:
>>> [*zip(*theArray)]
[('a', 'd', 'g'), ('b', 'e', 'h'), ('c', 'f', 'i')]
More Related Contents:
- How to make a flat list out of a list of lists?
- How to define a two-dimensional array?
- How do I make a flat list out of a list of lists?
- Sort multidimensional array based on 2nd element of the subarray
- How to access the elements of a 2D array?
- How to sort a 2D list? [closed]
- Converting List Comprehensions to For Loops in Python
- How can I turn a flat list into a 2D array in python?
- What does “list comprehension” and similar mean? How does it work and how can I use it?
- What’s the difference between lists and tuples?
- How to split a string into a list of characters?
- List comprehension on a nested list?
- How to return dictionary keys as a list in Python?
- Python: Removing list element while iterating over list [duplicate]
- Converting a String to a List of Words?
- In Python, when to use a Dictionary, List or Set?
- Check if something is (not) in a list in Python
- How to force a list to a fixed size?
- What is the inverse function of zip in python? [duplicate]
- Pandas expand rows from list data available in column
- How to remove all duplicate items from a list [duplicate]
- Unpack list to variables
- How to find common elements in list of lists?
- How to convert a string list into an integer in python [duplicate]
- Convert list of strings to dictionary
- Most efficient way for a lookup/search in a huge list (python)
- Sort list of strings by a part of the string
- How can I partition (split up, divide) a list based on a condition?
- Python: Rename duplicates in list with progressive numbers without sorting list
- How do I send list of dictionary as Body parameter together with Files in FastAPI?