You are viewing a single comment's thread. Return to all comments →
I have solved it using counter and orderedDict
from collections import Counter,OrderedDict ordered_dict = OrderedDict() for i in range(int(input())): string = input() if string in ordered_dict: ordered_dict[string] += 1 # value_lst.append(('len')) else: ordered_dict[string] = 1 # print(ordered_dict) print(len(ordered_dict.keys())) print(*ordered_dict.values())
lst = [] for i in range(int(input())): lst.append(input()) ct = Counter(lst) print(len(ct.keys())) print(*ct.values()) `print(*ct.values())
`
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 →
lst = [] for i in range(int(input())): lst.append(input()) ct = Counter(lst) print(len(ct.keys())) print(*ct.values()) `print(*ct.values())
`