Word frequency
Return a dict mapping each word to its count in the sentence.
List intersection
Return the sorted list of elements common to both lists.
Most frequent element
Return the element that appears most often in a list.
Word to Index Map
Create a function that returns a dictionary mapping each unique word to the index of its first occurrence.
Group names by first letter
Given a list of names, return a dictionary mapping each first letter to all names starting with that letter in original order.
Keys Sorted by Value Descending
Given a dictionary mapping strings to integers, return a list of keys sorted by value descending, and when values tie, alphabetically ascending.
Nested get with dotted path
Implement a function that safely retrieves a value from a deeply nested dictionary using a dot-separated path, returning a default if any key is missing.
Common Keys of Two Dictionaries
Implement a function that finds keys shared by two dictionaries and returns them sorted.
Union of Many Sets
Implement a function that takes any number of sets and returns a sorted list of their union.
Mode of a list via counting
Implement a function that returns the mode of a list, resolving ties by the element that appears first.
Top k keys by count
Given a dictionary mapping keys to counts, return the top k keys with the highest counts, breaking ties alphabetically.
Values that appear once
Return a list of numbers that appear exactly once in the input list, in original order.
Two Sum with Dict
Implement the classic Two Sum problem: return indices of two numbers that add up to a target using a dict.
Anagram Groups by Size
Group a list of words into anagram groups and return them sorted by group size and lexicographically.
Top K Frequent Words
Given a list of words, return the k most frequent words sorted by frequency (descending) and then alphabetically.
Symmetric Difference
Write a function that computes the symmetric difference of two lists, returning a sorted list of unique elements.
Showing 16 challenges · Dicts & Sets
Dicts & Sets — Python coding challenges
What you will find here
This page lists dicts & sets challenges — real Python problems you solve in the browser IDE with instant test feedback. Each challenge includes a clear brief, starter code, and automated checks.
Challenges vs tutorials and quizzes
Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.