word order hackerrank solution

 from collections import Counter

n =int(input())
L = []
for i in range(n):
    L.append(input())
    
c=Counter(L)
print(len(c))

print(*c.values())


for last line we can use below code as well

for i in c.values():
print(i ,end=" ")

Comments

Popular posts from this blog

Mean, Var, and Std in numpy HackerRank

Min and Max in numpy HackerRank

Collections.deque() HackersRank Solution