Transpose a 2D array
This snippet can be used to transpose a 2D array.
Python: 3.0    Fatos Morina    03 Jul 2021   0
Login to upvote
1
2
3
array = [['a', 'b'], ['c', 'd'], ['e', 'f']]
transposed = zip(*array)
print(transposed) # [('a', 'c', 'e'), ('b', 'd', 'f')]
Copy | Download as: .py file   PNG
Share on: FB   Twitter   LinkedIn   WA
©2021 - code108labs   Contributors   Hosted on DigitalOcean   Partner website: pythoncircle.com