Basic counting
Input
Hello, hello world!
Output
[('hello', 2), ('world', 1)]
The function lowercases words, strips punctuation and counts occurrences. 'hello' appears twice, 'world' once; sorted alphabetically.
Full lesson preview
Count how many times each word appears in a sentence, normalizing case and ignoring punctuation.
Problem statement
Task
Examples
Input
Hello, hello world!
Output
[('hello', 2), ('world', 1)]
The function lowercases words, strips punctuation and counts occurrences. 'hello' appears twice, 'world' once; sorted alphabetically.
Input format
Output format
Constraints
Samples
Input
One fish two fish
Output
[('fish', 2), ('one', 1), ('two', 1)]
Counts words and sorts result alphabetically.