CoreChallenge 15 of 34

Transpose a matrix

Write transpose(matrix) that flips a -of- over its diagonal: rows become columns. The matrix may be non-square.

Examples
transpose([[1, 2, 3], [4, 5, 6]]) → [[1, 4], [2, 5], [3, 6]]
Exercise

Transpose a matrix

4 checks
def transpose(matrix):
    ...


print(transpose([[1, 2, 3], [4, 5, 6]]))
 
Python (loads on first run)Ctrl+Enter runs
Output
Press Run to try your code, then Check answer to grade it.