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.
n = int(input())
word_list = list()
word_dict = dict()
for i in range (n):
w = input()
if w not in word_dict.keys():
word_list.append(w)
word_dict[w] = 1
else:
word_dict[w] += 1
print(len(word_dict))
for w in word_list:
print(word_dict[w], end=' ')
Cookie support is required to access HackerRank
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 →
Without ordered_dict or Counter