CurriculumAlgorithmic Thinking in Python, for KidsThe Dragon's Full Hoard Report
Practice Challenge: Combining Python's Loop Patterns
Max-tracking, counting, and searching — all three, on one list, composed without new tricks.
The Dragon's Full Hoard Report
You know three named patterns now: max/min-tracking, the counter, and search-with-a-flag. The challenge ahead uses all three, on the same list.
Each pattern keeps its OWN box and its OWN loop — running three patterns over one list is just running them one after another.
loot = [15, 200, 8]
highest = loot[0]
for v in loot:
if v > highest:
highest = v
count = 0
for v in loot:
if v > 50:
count = count + 1
print(highest, count)Output
200 1Nothing new here — just choosing the right pattern for each part of the question, and not letting one loop's box get confused with another's.
Check your understanding
You need BOTH the highest value in a list AND how many values are over 50. Can one single loop do both at once?
Why: Yes — one loop CAN do both, updating highest and count in the same pass, since neither check depends on the other. Separate loops (one per pattern) are often easier to read and are exactly what this topic's levels use, but combining them into one pass is also correct.
loot = [15, 200, 8, 45, 200, 3]. Using the counter pattern for values > 50, what's the count?
count = 0
for v in loot:
if v > 50:
count = count + 1Why: 2. The counter pattern just checks each item independently — it doesn't track which VALUES it's already seen, so two items with the same value both count separately if they both pass the test. loot has two 200s, and both are over 50.
What you'll practice
loot = [15, 200, 8, 45, 200, 3]. Find the highest value (max-tracking) AND count how many values are over 50 (counter). Print the highest, then the count.
More from this topic
The Dragon's Full Hoard Report is one lesson inside Algorithmic Thinking in Python, for Kids — see the full lesson order and what the whole topic covers.
View the full topic →