11.04
Completed
Looping over Dictionaries Looping over Dictionaries

Learn how to loop through dictionary keys, values, and key-value pairs, then build clear reports, totals, and filtered summaries.

Looping over Dictionaries

Sounds useful?

Jump into the interactive version.

No setup. No account. Just Python.

Interactive Python lesson

Looping over Dictionaries in Python

Dictionaries become much more useful when you can process every entry without writing a separate line for each one. This Block shows you the three essential looping styles: a plain loop for keys, .values() for values, and .items() when both parts matter.

You will use dictionary loops to print readable reports, calculate totals with an accumulator, filter entries with conditions, and avoid common mix-ups between keys and values.

What you will learn

  • Loop directly over a dictionary to visit its keys
  • Read matching values with bracket notation
  • Process values with .values()
  • Work with keys and values together using .items()
  • Combine dictionary loops with conditions and accumulators
  • Recognize common mistakes such as missing parentheses or mixing up keys and values

By the end, you will be able to choose the right loop for the job and turn a small dictionary into a clear report, total, or filtered summary.

> Start now 121 cards · about 11 min

Ready to practice this in the browser?

> Play now