You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict N = int(input()) word_dict = OrderedDict() for i in range(N): word = input() if word in word_dict: old_word_count = word_dict[word] new_word_count = old_word_count + 1 word_dict[word] = new_word_count else: word_dict[word] = 1 word_count_list = [ str(word_dict[i]) for i in word_dict ] print(len(word_count_list)) print(" ".join(word_count_list))
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 →