s='abcdd' s='aabbccdd' ls=[] ds=[] for i in s: if i not in ls: if ls: ds.append([ls[0],len(ls)]) ls=[] ls.append(i) else: ls.append(i) ds.append([ls[0], len(ls)]) mins=min([x[1] for x in ds]) for i in ds: if i[1]==mins: s=s.replace(i[0],'') if not s: print('enpty') else: print(s)
03-16
131
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-10
482
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-14
136
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-17