Python Program to find Matrix Transpose

Last Updated:

Find Matrix Transpose

In the following example, we will transpose the given matrix (two-dimensional array).

Example

Python Compiler
arr1 = [ [1, 1, 1], [2, 2, 2], [3, 3, 3] ] arr2 = [[0]*3 for _ in range(3)] print("Enter Matrix (3 x 3):") for i in range(0, 3): for j in range(0, 3): print(arr1[i][j], end=" ") print() for i in range(0, 3): for j in range(0, 3): arr2[i][j] = arr1[j][i] arr2[j][i] = arr1[i][j] print("\nMatrix Transpose:") for i in range(0, 3): for j in range(0, 3): print(arr2[i][j], end=" ") print()

Share this Page

Meet the Author