We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Collections
- Word Order
- Discussions
Word Order
Word Order
Sort by
recency
|
1649 Discussions
|
Please Login in order to post a comment
n=int(input())
k={} list1=[]
for i in range(n): stri=input() list1.append(stri)
for i in list1: k[i]=k.get(i,0)+1 print(len(k)) for i ,p in k.items(): print(p,end=" ")
from collections import Counter
n = int(input().strip()) words = [input().strip() for _ in range(n)]
words_count = Counter(words)
distinct = [] for w in words: if w not in distinct: distinct.append(w)
print(len(distinct))
for d in distinct: print(words_count[d], end=" ") print()