Python: List: Transpose

Write the function transpose that takes a matrix (list of lists) matrix and returns its transpose. All lists inside matrix have the same length. More information about matrix transpose can be found here. No external library such as numpy cannot be used. All tests would fail if any library is imported in your solution.


transpose([[1,2,3],[4,5,6]]) -> [[1,4],[2,5],[3,6]]
transpose([[1,2,3,4]]) -> [[1],[2],[3],[4]]

Test 1    

Test 2    

Test 3    

Test 4    

Test 5    

Test 6