Practice Challenge: Loops, Counting, and Decisions Together

Loops, counting, and decisions — all working together, pass after pass.

  • Lesson 4 of 5
  • PRO
  • Ages 10+
  • 3 hands-on levels
See what PRO unlocksA one-time $49.99 purchase. Topics 1–3 are free.

The dragon explains

The Dragon Patrol

  1. The dragon: One more trick before the challenge: you can loop over a LIST directly, not just numbers from range().

  2. The dragon: for strength in strengths: visits each value in the list, one at a time — no range() or index needed.

    example.pyPython 3
    strengths = [30, 60, 90]for strength in strengths:    print(strength)
    Output30 60 90
  3. The dragon: And you can put an if/elif/else INSIDE a loop — the same decision, made fresh on every single pass.

Quick check

Check your understanding

Say your answer out loud before reading the marked one. Every wrong option is a mistake real beginners make.

  1. Question 1 of 1

    strengths = [30, 60, 90]. Using if/elif/else with 80 and 40 as cutoffs, how many lines print in total?

    • 3 — one reaction per dragonCorrect
    • 9 — every dragon checked against every rule
    • 1 — only the last dragon's strength matters

    Why: Three dragons, one loop pass each, one if/elif/else decision each — three lines total. The loop and the conditional work together: the loop provides how many times, the conditional provides which reaction each time.

In the game

What you'll practice

Three levels in the game: one guided first try with the shape of the answer already there, then two to solve on your own.

  1. 1

    GuidedYour first try

    Print each chest number (0 to 4) AND keep a running total of 100 gold added per chest, printing the total after each one.

  2. +2

    PracticeTwo more, on your own

This lesson is part of PRO.

PRO is a one-time $49.99 purchase, no subscription, and unlocks this whole topic along with everything else. Topics 1–3 are free, start to finish.

Unlock this lesson with PRO

Stuck three times? The game offers the answer — unasked.