Python zip () function for matrix

Possible duplicate:
Transpose Matrix in Python

I have a matrix, let's say

A = [[0,0],[1,1]] 

and I would like to fix its components so that

 (0,1),(0,1) 

With two lines in, this can be easily obtained using

 zip(A[0],A[1]) 

What if I have a matrix A of any dimension

 A = [[0,0],[1,1],[2,2]] 

How to fix a sequence of elements?

Thanks for your ideas.

+4
source share
1 answer

Use zip(*A) .

 >>> zip(*A) [(0, 1, 2), (0, 1, 2)] 
+6
source

All Articles