source=[1,2,3,4,2,3,5,6]
dst=[]
for item in source:
if item not in dst:
dst.append(item)
print(dst) # [1,2,3,4,5,6]
我可以像这样简化上面的代码吗:
dst=[item for item in [1,2,3,4,2,3,5,6] if item not in 'this array']
谢谢
最佳答案
关于python - 在 python 中创建列表的 "for"循环和 "if"条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47885362/