Loading...
Loading...
Loading...
Given a line of words, report how many times each different word appears.
Print one line per word as word count, in the order the words first appear.
Example
Input
north south north east south north
Output
north 3 south 2 east 1
North appears three times, south twice, east once.
Try the problem first. Open one hint at a time.
Count with a dictionary. Dictionaries remember the order in which keys were added.
After counting, loop over counts.items() and print each pair.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor