Skip to content

Commit 4d13091

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent e282f87 commit 4d13091

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

matrix/transpose_of_matrix.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
finding tanspose of the given matrix
3-
The transpose of a matrix is a new matrix formed by
4-
flipping the original matrix over its main diagonal,
3+
The transpose of a matrix is a new matrix formed by
4+
flipping the original matrix over its main diagonal,
55
effectively interchanging its rows and columns
66
suppose A=[[1,2,3],
77
[4,5,6],
@@ -16,23 +16,23 @@
1616
3.copy the elements in oppposite order of the traversl
1717
i.e. trans[j][i]=matrix[i][j]
1818
"""
19+
20+
1921
def transpose(matrix):
20-
#create a null matrix of same dimension of given matrix
21-
trans=[[0]*len(matrix) for _ in range(len(matrix[0]))]
22+
# create a null matrix of same dimension of given matrix
23+
trans = [[0] * len(matrix) for _ in range(len(matrix[0]))]
2224
for i in range(len(matrix)):
23-
#row wise traversal
25+
# row wise traversal
2426
for j in range(len(matrix[0])):
25-
#column wise traversal
26-
trans[j][i]=matrix[i][j]
27-
#copying the elements in null matrix
27+
# column wise traversal
28+
trans[j][i] = matrix[i][j]
29+
# copying the elements in null matrix
2830
return trans
29-
#checking for main function
30-
if __name__=="__main__":
31-
#matrix(given)
32-
mat=[[1, 2, 3],[4, 5, 6]]
33-
#call the function with mat as parameter
34-
print(transpose(mat))
3531

3632

37-
38-
33+
# checking for main function
34+
if __name__ == "__main__":
35+
# matrix(given)
36+
mat = [[1, 2, 3], [4, 5, 6]]
37+
# call the function with mat as parameter
38+
print(transpose(mat))

0 commit comments

Comments
 (0)