Python Transpose list of lists 网页链接
1. Map with Zip
solution1 = map(list, zip(*l))
2. List Comprehension
solution2 = [list(i) for i in zip(*l)]
3. For Loop Appending
solution3 = []
for i in zip(*l):
solution3.append((list(i)))
And to view the results:
pr
how to print array as a table in python网页链接
for line in Table:
print ' '.join(map(str, line))
It's prettier in Python 3:
for line in Table:
print(*line)