You are viewing a single comment's thread. Return to all comments →
from itertools import groupby
test_input = input()
res = groupby(test_input)
print(' '.join([str((len([item for item in g]),int(k))) for k, g in res]))
Seems like cookies are disabled on this browser, please enable them to open this website
Compress the String!
You are viewing a single comment's thread. Return to all comments →
from itertools import groupby
test_input = input()
res = groupby(test_input)
print(' '.join([str((len([item for item in g]),int(k))) for k, g in res]))