HackerRank Python - Word Order
You are given n words. Some words may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. See the sample input/output for clarification.
- # Enter your code here. Read input from STDIN. Print output to STDOUT
- from collections import OrderedDict
- dict = OrderedDict()
- for _ in range(int(input())):
- key = input()
- dict[key] = dict.get(key, 0) + 1