Codele / Programming basics
Chains of choices
Sometimes two paths are not enough. The computer can ask one question after another, and the first “yes” wins.
- More than two paths? Ask questions in order: if, then else if (elif in Python), then else.
- The first yes wins. The rest of the chain is skipped.
- The last else has no question. It catches everything the questions above did not.
- Order matters. Put the questions in the order you want them asked.
- Lines after the chain run either way.
Loading the playable lesson…