You are viewing a single comment's thread. Return to all comments →
# 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=' ')
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Compress the String!
You are viewing a single comment's thread. Return to all comments →
# 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=' ')