You are viewing a single comment's thread. Return to all comments →
n = int(input()) dic = {}
for _ in range(n): word = input() if word not in dic.keys(): dic[word] = 1 elif word in dic.keys(): dic[word] = 1+dic[word]
print(len(dic)) quan = list(dic.values())
print(" ".join(map(str,quan)))
Seems like cookies are disabled on this browser, please enable them to open this website
Word Order
You are viewing a single comment's thread. Return to all comments →
n = int(input()) dic = {}
for _ in range(n): word = input() if word not in dic.keys(): dic[word] = 1 elif word in dic.keys(): dic[word] = 1+dic[word]
print(len(dic)) quan = list(dic.values())
quan.sort(reverse=True)
print(" ".join(map(str,quan)))