You are viewing a single comment's thread. Return to all comments →
s = input() groups = [] for i, c in enumerate(s): if i > 0 and s[i-1] == s[i]: last = groups[-1] groups[-1] = (last[0] + 1, int(c)) else: groups.append((1, int(c))) print(*groups)
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 →