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
|
848 Discussions
|
Please Login in order to post a comment
# Enter your code here. Read input from STDIN. Print output to STDOUT from itertools import groupby
s= input().strip()
for key , group in groupby(s): print(f"({len(list(group))}, {key})",end=' ')
Without itertools using sliding window concept.