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))

3 views0 comments

Recent Posts

See All

Binary string reduction in Python

Asked: Sudeep |Category: Python x=int(input("Enter the value of x : ")) for i in range(x): n=int(input("Enter the value of n : ")) y=input("Enter the value of y : ") l=list(y) k=0

"Believe you can and you're halfway there"