Sum sales by category
Your task
A shop's daily sales feed stores one line item per row as "category,amount", where amount is an integer that may be negative (a refund). Build the mini pivot the manager sees each evening: a dictionary mapping each category to the sum of its amounts. Example: ["toys,20", "games,15", "toys,5"] gives {"toys": 25, "games": 15}.
Examples
category_totals(rows: list[str]) -> dict[str,int]Example 1
Input
category_totals(["toys,20", "games,15", "toys,5"])Output
{"toys": 25, "games": 15}