Compress the String!

  • + 0 comments
    from itertools import groupby
    
    c = input()
    c_final = []
    
    for key, group in groupby(c):
        key = int(key)
        c_final.append((len(list(group)), key))
        
    print(*c_final)