res = []
for e in s:
if len(res) < 2:
res.append(e)
continue
if len(res) >= 2:
if e == res[-1] and e == res[-2]:
continue
if len(res) >= 3:
if e == res[-1] and res[-2] == res[-3]:
continue
res.append(e)
print("".join(res))
检查单词中字母不合情况的重复,并删除
最新推荐文章于 2021-05-17 10:08:23 发布