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
|
1636 Discussions
|
Please Login in order to post a comment
no modules required
n=int(input()) d={} for i in range(n): w=input() if w in d.keys(): d[w]+=1 else: d[w]=1 print(len(d)) for i in d.keys(): print(d[i],end=' ') print()
With Counter in Collection Module:
Without Counter in Collection module (Conventional Approach):
from collections import Counter N = int(input()) D = [] for i in range(N): D.append(input()) print(len(set(D))) print(*Counter(D).values())