# for i, value_i in enumerate(list_a):
# list_intercept = list_a[i: ]
# j = [k for (k, value_k) in enumerate(list_intercept) if (value_k == value_i)][-1] + i
# print(i, value_i, list_intercept, j, f'{i}: {j}', list_a[i: j+1], sep='\t')
# print(sep='\n')
list_example = ['A', 'A', 'B', 'B', 'C', 'C']
# 取唯一值
list_sorted = sorted(set(list_example), key=list_example.index) # set后需排序 # list(set(list_example)) == ['B', 'C', 'A'] # 不能用中括号转化[set]
dict_example = {key: value for key, value in enumerate(list_example)}
for i in list_sorted:
dict_i = {key: value for key, value in dict_example.items() if (value == i)}
print(dict_i, f"{list(dict_i.keys())[0]}: {list(dict_i.keys())[-1]}")