python matrix transpose and zip
question answers:
>>> import numpy as np
>>> first_answer = np.transpose(a)
>>> second_answer = [list(i) for i in zip(*a)]
thanks to afg for helping out
Use zip(*a)
:
>>> zip(*a)
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
How it works: zip(*a) is equal to zip(a[0], a[1], a[2]).