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.
- store the words as they come in the Counter.
- print them.
🧾 I hope you remember,
Counterafter python 3.7 internally maintains insertion order.
from collections import Counter words = list() #n -> no of words n = int(input()) for _ in range(n): words.append(input()) c =Counter(words) print(len(c)) print(*c.values())