Compress the String!

  • + 0 comments
    from itertools import groupby
    s = input()
    for char, grouped_iter in groupby(s):
        print(f"({len(list(grouped_iter))}, {char})", end = " ")