Build a Word Counter
Intermediate · Write the code · from Python Dictionaries: The Complete Guide with Real Examples
From the lesson: Python Dictionaries: The Complete Guide with Real Examples
Open the contacts app on your phone. You look up a person by name and get their phone number. You don't search by position - you don't say "give me contact number 47." You search by name.
Read the lessonCount how many times each word appears in the given list. Store the counts in a dictionary called word_counts, then print it.
Expected output:
{'hello': 3, 'world': 2, 'python': 1}words = ['hello', 'world', 'hello', 'python', 'hello', 'world']
# Build a word count dictionary
# Print the result
More Dictionaries exercises
- Create a Dictionary and Access a ValueBeginner
- Add and Modify Dictionary EntriesBeginner
- Safe Access with get()Beginner
- Loop Through a DictionaryBeginner
- Predict the Output: Duplicate KeysBeginner
- Fix the Bug: Checking for a ValueIntermediate
- Access Nested Dictionary DataIntermediate
All Python exercises · 50 practice problems · Data Structures quiz