gyk
3 years ago in Python
string = 'KKKKKKKEEEEEERRRRRRTTTTJJJJJJJTTTZZZZZZZZZZZRRRRR'
print(string)
label = 2
offset = 1
for 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}}')