LessonΒ·difficulty 2/5Β·~15 min
Group sales by category
Implement sales_by_category(rows).
Each row has a string category and an integer amount. Return a dictionary of total amount per category. Negative amounts represent refunds and must be included. Empty input returns {}.
Before coding, predict one result by hand. After the tests pass, explain your approach and add a boundary example of your own.
Tests
- Case 1
- Case 2
- Case 3
β¦ Stuck? Ask for a spark
Sign in or create a free account to use your monthly AI explainer allowance.
warming up
Loading editorβ¦
Consolewaiting
$ Console output will appear here.