2 of 9
Write a function grid_sum(grid) that takes a 2D list of integers and returns the sum of all numbers in the grid.
grid_sum(grid)
grid1 = [ [1, 2, 3], [4, 5, 6] ] print(grid_sum(grid1)) # 21 grid2 = [ [10, -5], [3, 7], [2, -1] ] print(grid_sum(grid2)) # 16
Previous
Grids, DFS & BFS — Intro & Concepts
Next
Find Position