The Standard Library Exists · practice
Count with Counter
The briefing’s second job is to count activity categories. You could build a Counter.
The collections.Counter constructor accepts an
The missing category prints 0. A regular dictionary lookup would raise
Separate counting from presentation
Our records are dictionaries:
{"date": "2026-08-03", "category": "walk", "minutes": 35}
Counter needs the category values, not whole dictionaries. Build a Counter.
Do not format a sentence yet. A Counter is useful data that the capstone can order and present later. Counter remembers encounter order, but encounter order is not an alphabetical report contract. Keeping those decisions separate will make the final output deterministic.
What should count_categories(records) pass to Counter?
Add the second days_between work you already completed.
Task
Implement count_categories(records) in activity_report.py.
Each record is a date, category, and minutes keys.
Visit every record and collect its
category. Construct and return a
collections.Counterfrom those categories.For an empty
, return an empty Counter naturally.
Keep returning data rather than a formatted sentence. The capstone will decide how counts should appear.