LearnPy Hub
← Comprehensions problems
Medium

Word Count Dictionary

Read words and print a dictionary of each distinct word (in order of first appearance) and how many times it appears, using one dictionary comprehension over dict.fromkeys(words).

Input

Words separated by spaces.

Output

A dictionary.

Sample 1

Input
a b a c b a
Output
{'a': 3, 'b': 2, 'c': 1}

Sample 2

Input
hello
Output
{'hello': 1}
solution.py
Output appears here
Word Count Dictionary · Python practice problem · LearnPy Hub