Exercise 1: Grid Sum

Your Task

Write a function grid_sum(grid) that takes a 2D list of integers and returns the sum of all numbers in the grid.


Examples

grid1 = [ [1, 2, 3], [4, 5, 6] ] print(grid_sum(grid1)) # 21 grid2 = [ [10, -5], [3, 7], [2, -1] ] print(grid_sum(grid2)) # 16

Hints

Try it yourself

Code: Grid Sum

Loading Python runtime…
Python …
Loading...
bash
$ Click "Run" to execute your code...