Compress the String!

  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    from itertools import groupby
    
    S = input()
    for i, combo in groupby(S):
        grp = len(list(combo))
        print((grp, int(i)), end=' ')