View Code of Problem 36

import collections
n=eval(input())
for i in range(n):
    s = input()
    d = collections.OrderedDict()
    for i in s:
        if d.get(i):
            d[i] += 1
        else:
            d[i] = 1
    for i in d:
        print("%d%c" % (d[i], i), end='')
    print()

Double click to view unformatted code.


Back to problem 36