Practice · Python

Practice Dict Iteration & Counting

Iterate keys/values/items and implement frequency-counting (histogram) patterns with dictionaries.

Dict Iteration & Countingwarming python…

Find the most common space item

Write a function most_common_space_item(items) that receives a list of strings representing names of space objects (e.g., planets, moons). It should count how many times each name appears, then return the name that occurs most often. If the list is empty, return None. If several names share the highest count, return the one that appears first in the input list.

most_common_space_item(["Mars","Venus","Mars","Jupiter"])  # returns "Mars"
most_common_space_item([])  # returns None
Press Run to see output, or Check to grade against the tests.

Want a whole course built around dict iteration & counting?

Start my path — free

Adaptive practice, streaks, projects with real code review. Free tier gates AI help, never content.

Practice Python: Dict Iteration & Counting — CodeArcade