9. Choosing Values

x if condition else y

2 if b % 2 == 0 else 1 is a one-line choice: it gives 2 when the condition is true and 1 when it isn't. You can use it anywhere a value goes.

🎯 0/4 · 🥁 0 solved · 🏅 0

Challenge A:Loop 1-8 and play hihat(b, 2 if b % 2 == 0 else 1) — two hits on even beats, one on odd.

Goal
hihat
1234
5678