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
|
836 Discussions
|
Please Login in order to post a comment
from itertools import groupby s=list(input()) for k,g in groupby(s): print(f"({len(list(g))}, {k})", end=" ")
from itertools import groupby data = input() result = [(len(list(group)),int(key)) for key,group in groupby(data)] print(*result)
from itertools import groupby
s=input()
for key, group in groupby(s): group_list=list(group) key=int(key) print (tuple((len(group_list),key)),end=" ")