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
- Return a count dictionary for supplied labels.
- Avoid mutable default arguments.
- 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.