We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Itertools
- Compress the String!
- Discussions
Compress the String!
Compress the String!
Sort by
recency
|
825 Discussions
|
Please Login in order to post a comment
from itertools import groupby
s = input()
for k, g in groupby(s): print((list(g).count(k),int(k)), end = " ")
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))