Return a dictionary of lower-case word counts for a sentence, ignoring repeated whitespace and simple punctuation at word edges.
Requirements
Normalize words to lower case
Do not count empty strings
Return a new dictionary
Example
Input
Build, build reliable programs!
Expected output
{
"build": 2,
"reliable": 1,
"programs": 1
}
Show a hint
Write down the input contract and the failure cases before coding.
local runtime
RUNTIME OUTPUT
Use your Python runtime locally, then compare with solution.py.
Use your local runtime, then review the reference solution
LEARN FROM THE SOLUTION
Why the solution works.
split handles repeated whitespace without special cases. The dictionary keeps one count per normalized word, and get supplies the zero value needed for the first occurrence.
What this exercise teaches
Dictionaries
String normalization
Loops
A PRACTICAL PLAN
Work through Count unique words with intent.
Translate the contract.Turn the requirements into a short checklist before editing your-solution.py.
Use the example as evidence.Predict the result for the supplied input, then add one boundary case such as an empty value, a limit, or unexpected input.
Review the implementation.Compare your choices against solution.py only after a real attempt.
EXERCISE FAQ
Before you move on.
What does “Count unique words” teach?
This beginner Python exercise focuses on Dictionaries, String normalization, Loops. Its requirements define the exact behavior to implement before you write code.
How should I validate this Python solution?
Start with the displayed example input and expected output, then test a boundary case suggested by the requirements. Write and compile the starter in your local Python environment, exercise the example and edge cases, then compare your approach with solution.py.
When should I open the reference solution?
Attempt Count unique words first. Then open the read-only solution file to compare the contract, edge-case handling, and implementation choices—not simply to copy the final code.