Skip to content
C

Word Frequency Counter

Easypython

Given a sentence, count how many times each word appears, using a dictionary.

Approach: split the sentence into words, then loop through them, using dict.get(word, 0) + 1 to increase each word's count — building up one dictionary of word -> count.

Input: One line: a sentence of space-separated words.

Output: One line: a Python dictionary mapping each word to how many times it appeared, in order of first appearance.

Input (stdin)

Output

Run your code to see output here...