P48PythonBeginnerImplement6 min

Implement a Safe Running Category Counter

Update category counts without hidden shared state between calls.

#implement#dictionaries#state

Scenario

A notebook helper counts order categories. The second daily run includes counts from the first even though it receives new orders.

Problem statement

Write a safe counter helper.

Your Task

  1. Return a count dictionary for supplied labels.
  2. Avoid mutable default arguments.
  3. Explain why repeated calls stay independent.

Related Concepts

DictionariesMutable defaultsState

Ready to count this problem?

Mark it complete when you have reasoned through the solution in your own words.