string = 'KKKKKKKEEEEEERRRRRRTTTTJJJJJJJTTTZZZZZZZZZZZRRRRR'print(string)label = 2offset = 1for i in range(len(string)): try: if string[i] != string[i+1]: print(f'{label:<{offset}}', end='') offset = 1 label += 2 else: offset += 1 except IndexError: print(f'{label:<{offset}}')
123456789101112131415