HackerRank Python - Compress the String
In this task, we would like for you to appreciate the usefulness of the groupby() function of itertools . To read more about this function, Check this out .
- # Enter your code here. Read input from STDIN. Print output to STDOUT
- from itertools import groupby
- for key, group in groupby(input()):
- print((len(list(group)), int(key)), end=' ')