x = (1,1,-13,8,5,0,4,-1,-4)
a = filter(lambda i,j: i == j, x)
print(tuple(a))
我收到一个错误,而不是正确的答案(1,-13,8,5,0,4,-1,-4)
。我怎么了
x = (1,1,-13,8,5,0,4,-1,-4)
seen = []
answer = []
for elem in x:
if elem not in seen:
seen.append(elem)
answer.append(elem)
print(tuple(answer))
Ouput:
(1, -13, 8, 5, 0, 4, -1, -4)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句