Track 6 · Lesson 6 of 12
Dictionary patterns: count, group, invert
Loop over keys, values and items, and use dictionaries to count occurrences, group records, invert mappings and total by category.
You will be able to
- Loop over a dictionary's keys, values and items
- Count occurrences with the get(key, 0) + 1 pattern
- Group items into lists under a key and total values by category
- Invert a mapping and recognise what happens with duplicate values
Included with a Formula Quest membership
It has 5 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.
View Formula Quest memberships
Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.