s='aabbcddc'
要求输出 2,2,4
s = 'aabbcddc'
dic = {}
lis = []
new_start = 0
for index,i in enumerate(s):
if index <= new_start:#如过小于上次的结束值,跳过
continue
else:
start = index
start_value = i
max_index = []#记录同个字符的最长长度
for index0,i0 in enumerate(s):
if i0==start_value:
max_index.append(index0)
print(max(max_index)-min(max_index)+1)#输出距离差
new_start=max(max_index)