检查列表中的项目

时间:2019-10-11 04:02:02

标签: python-3.x

检查列表中的项目 检查列表中的项目 检查列表中的项目 检查列表中的项目

1 个答案:

答案 0 :(得分:0)

不确定这是否是您想要的东西,但是可以解决:

from itertools import permutations 
s = ['8','role','lore','pre','erp','elor','orle','rep']
res = []
anag = set()
for x in s:
    if x in anag:
        continue
    res.append(x)
    for per in permutations(x):
        anag.add(''.join(per))
res = sorted(res)
#['8', 'role', 'pre']
相关问题