Exercise 3: Sum the Rows of a Matrix
Write code that calculates the array produced by summing the entries of each row of a matrix.
We'll cover the following
Problem statement
In this exercise, you’re given a nested array. Sum the entries in each row of the matrix and return an array containing these sums.
Example
For example, consider the following array:
nested_array = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
We get the following output in return:
[6, 15, 24]
Try it yourself
def sum_the_cols(nested_array)result = []# Start your code herereturn resultend