I'm trying to create a matrix transpose function in Python. A matrix is a two-dimensional array, represented as a list of lists of integers. For example, the following is a 2X3 matrix (meaning the height of the matrix is 2 and the width is 3):
A=[[1, 2, 3],
[4, 5, 6]]
To be transposed the jth item in the ith index should become the ith item in the jth index. Here's how the above sample would look transposed:
>>> transpose([[1, 2, 3],
[4, 5, 6]])
[[1, 4],
[2, 5],
[3, 6]]
>>> transpose([[1, 2],
[3, 4]])
[[1, 3],
[2, 4]]
How can I do this?