A frequency table stores one count per distinct key. The first occurrence can use zero as its previous count.
A game keeps a running score by team.
scores = {}
for team, points in [("Red", 3), ("Blue", 2), ("Red", 4)]:
scores[team] = scores.get(team, 0) + points
print(scores) # {'Red': 7, 'Blue': 2}The two Red entries use the same key. Ticket labels may differ in spaces and capitalization, so decide which key each label should use before counting it.
Complete ticket_counts(tickets). Trim and lowercase each ticket type, ignore blank entries, and return a dictionary of counts.
ticket_counts([" Day", "day ", "", "Week"]) # {"day": 2, "week": 1}