Home > Tips & Tricks > Transpose of a Matrix in Python

# Transpose of a Matrix in Python

A matrix in python is a rectangular array packed with symbols, expressions, alphabets, and numbers that are arranged in rows and columns but we can transpose it.

Transpose matrix means, rows will become columns and columns become rows. We can do this with the python NumPy function `transpose()` and creating a loop structure that iterates through the elements in the matrix and moves them around. It is very messing to design the loop structure and to replace the array elements with rows and columns.

But in this tutorial, we will do this without NumPy and without any array looping. We will use this tricky function to achieve it. Let’s see it.

```a = [[23, 56],
[37, 78],
[14, 24]]

print (zip(*a))```

In the above, we used `zip()` function to grouped the array with their respective elements. And used the `*` operator to unzip the array.

So when we run this python code then you will get the transpose matrix as an output.

#### OUTPUT:

`[(23, 37, 14), (56, 78, 24)]`