1. Rows and Columns

Lists of lists

A grid is a list of rows, and each row is a list. grid[1][3] means row 1, column 3 — both counting from 0. That's exactly how a drum machine's grid of buttons works.

Lesson 2: numbers in a grid become hits.

drums = [hihat, snare]
grid = [[2, 2, 2, 2], [0, 0, 1, 0]]
for r in range(2):
    for c in range(4):
        if grid[r][c] > 0:
            drums[r](c + 1, grid[r][c])
The beat it plays
hihat
snare
1234
…and in RockBlocks
Hi-Hat (Closed)
Snare Drum
🎯 0/4 · 🥁 0 solved · 🏅 0

Challenge A:grid = [[1, 0, 1, 0]]. Loop c over range(4) and play the kick on c + 1 when grid[0][c] == 1.

Goal
kick
1234