2 of 6
Given a grid of numbers, print the sum of each row.
grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]
Expected output:
Row 0: 6
Row 1: 15
Row 2: 24
grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] for r in range(len(grid)): total = ___ for num in ___: total += ___ print(f"Row {r}: {total}")
Start each row's total at 0: total = 0
Loop over each number in the current row: for num in grid[r]:
Add each number to the total: total += num
grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] for r in range(len(grid)): total = 0 for num in grid[r]: total += num print(f"Row {r}: {total}")
How it works:
total to 0✅ Standard library: heapq, collections, itertools, math, random, functools, datetime, bisect
✅ Functions, classes, recursion, print()
❌ No file system, subprocess, OS access, or network requests
❌ No pip install (all supported modules are pre-loaded)
⏱️ 5 second execution time limit