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
|
830 Discussions
|
Please Login in order to post a comment
s = input().strip() for key, group in groupby(s): key = int(key) result = [(len(list(group)), key)] print(' '.join(map(str, result)), end = " ")
from itertools import groupby A = input() for k, g in groupby(A): print(f"{len(list(g)), int(k)}", end=' ')