• + 1 comment

    import collections

    n = int(input()) odi = collections.OrderedDict()

    for word in range(n): word = input() odi[word] = odi.setdefault(word, 0) + 1

    print(len(odi)) print(*list(odi.values()))

    • + 0 comments

      This was using OrderedDict and setdefault()