Transpose of a matrix

 m=int(input("number of rows"))

n=int(input("number of coulns"))

a=[]

for i in range(m):

    a.append([int(j) for j in input().split()])  

res=[[a[j][i] for j in range(len(a))] for i in range(len(a[0]))] 

for i in res:

    print(i)

No comments:

Post a Comment