← back to unit
Easy
# power tools easy
The Tally Machine
The candy shop logs every sale, and the owner asks about one candy at closing time. 🍭
You get the day's sales and one query candy. Count every candy with a dict in ONE pass, then print how many times the query sold (0 is possible).
Example:
Input: sales = ["cola", "mint", "cola", "gum", "cola"], query = "cola"
Output: 3
Walking through sales and tallying with counts.get(s, 0) + 1 each time, "cola" climbs to a count of 3.
💡 need a hint?
pt-tally-machine.py🔒 given lines are locked — write your code in between
loading...