Codington
0 of 6 problems solved • 0%

Exercise prompt

Count Ticket Types

A frequency table stores one count per distinct key. The first occurrence can use zero as its previous count.

Example

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.

Your task

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}