+ 1
If this is my matrix how to print the sum of each column?
m=[1,2,3] n=[4,5,6]
4 Answers
+ 3
you can do this with the help of numpy module it's all about matrix.you can do everything with your matrix with the help of numpy module check out these lessons from solelearn.
https://www.sololearn.com/learn/6671/?ref=app
check this lesson for sum of columns.
https://www.sololearn.com/learn/6685/?ref=app
+ 2
m = [[1, 2, 3], [4, 5, 6]]
mT = list(zip(*m))
print([sum(column) for column in mT])
#First take a transpose and then output sum
+ 2
Pranay Bhoir. You can save the sums in a variable and then access single elements.. Like sums[0] or sums[1]
OR, check out the str.join function
+ 1
yash
how to print sum without showing it in list brackets?