You are viewing a single comment's thread. Return to all comments →
from itertools import groupby
s = input().strip() result = []
for key,group in groupby(s): count = len(list(group)) result.append(f"({count},{key})")
print(" ".join(result))
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
s = input().strip() result = []
for key,group in groupby(s): count = len(list(group)) result.append(f"({count},{key})")
print(" ".join(result))