1. Default Inputs

Inputs with default values

def hit(b, hits=1): gives hits a default. Call hit(3) and hits is 1; call hit(3, 4) and it's 4. Defaults make functions easy to use and flexible.

Lesson 1: a roll function with smart defaults.

def roll(start=5, length=4):
    for b in range(start, start + length):
        tom(b)

roll()
roll(1, 2)
The beat it plays
tom
1234
5678
…and in RockBlocks
Mid Tom
🎯 0/4 · 🥁 0 solved · 🏅 0

Challenge A:Write def hit(b, hits=1): that plays snare(b, hits). Call hit(1) and hit(3, 2).

Goal
snare
1234