Transpose means is to interchange rows and columns of a two-dimensional array matrix.

[A^(T)]ij=[A]ji

ie:
Formally, the i th row, j th column element of AT is the j th row, i th column element of A:



Example :

```
[[1,2,3],[4,5,6]].transpose() //should return [[1,4],[2,5],[3,6]]
```

Write a prototype transpose to array in JS or add a .transpose method in Ruby or create a transpose function in Python so that any matrix of order ixj 2-D array returns transposed Matrix of jxi .

Link:  To understand array prototype

Difficulty: introductory

Starter code:

def transpose(arr):
	

Solutions:
import numpy as np

def transpose(A):
    if len(A) == 0:
        return []
    return np.array(A, dtype = 'O').T.tolist() if len(A[0]) > 0 else [[]]

def transpose(arr):
    if arr and not any(map(bool,arr)): return [[]]
    return list(map(list,zip(*arr)))

def transpose(arr):
    tran_each = []
    tran_com = []
    if len(arr) > 0 and len(arr[0]) > 0:
        n_row = len(arr[0])
        n_col = len(arr)
        for j in range(n_row):
            for i in range(n_col):
                tran_each.append(arr[i][j])
            tran_com.append(tran_each)
            tran_each = []
        return tran_com
    elif len(arr) > 0:
        return [[]]
    else:
        return []

def transpose(arr):
    lst = []
    if len(arr) == 0:
        return arr
    for i in range(len(arr[0])):
        lst.append([arr[j][i] for j in range(len(arr))])
    return [[]] if not lst else lst

def transpose(arr):
    if len(arr) == 0:
        return []
    if len(arr[0]) == 0:
        return [[]]
    return [[arr[row][col] for row in range(len(arr))] for col in range(len(arr[0]))]

def transpose(arr):
    return [] if arr==[] else [[]] if arr[0]==[] else [[arr[i][j] for i in range(len(arr))] for j in range(len(arr[0]))]