Matrices and grids · 6 / 15 Exercise Easy

Row and column sums

Objective

A matrix is a list of lists. Summing each row is direct with sum(row); for the columns, zip(*m) transposes it.

Instructions

  • The first line has the number of rows f and columns c; then come f lines with the values separated by spaces.
  • Show Rows: ... with the sum of each row and Columns: ... with that of each column, values separated by spaces.
Input
2 3
1 2 3
4 5 6
Output
Rows: 6 15
Columns: 5 7 9

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise