Print the sum of rows of a matrix.

Asked: Anonymously |Category: Python

n1=input(" Enter the dimension of matrix: ")

n1=int(n1)

n=[]

l=[0]*n1

c=0

for i in range(0,n1):

new=[]

for j in range(0,n1):

new.append(0)

n.append(new)

for i in range(0,n1):

l=[int(i) for i in input().split(" ")]

for j in range(0,n1):

n[i][j]=l[j]

for i in range(0,n1):

c=0

for j in range(0,n1):

c=c+n[i][j]

print("Sum of row number {0} is {1}".format(i+1,c))

2 views

Recent Posts

See All

"Believe you can and you're halfway there"