Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python transpose

l = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

t = list(zip(*l))
# t = [(1, 4, 7), (2, 5, 8), (3, 6, 9)] # list with tuples

t = list(map(list, zip(*l)))
# t = [[1, 4, 7], [2, 5, 8], [3, 6, 9]] # list with lists
# t = [*map(list, zip(*l))] works as well
 
PREVIOUS NEXT
Tagged: #python #transpose
ADD COMMENT
Topic
Name
9+4 =