gpt4 book ai didi

python - 如何找到可能有重复数字的 3 个列表之间的差异

转载 作者:太空狗 更新时间:2023-10-30 01:21:10 24 4
gpt4 key购买 nike

<分区>

我有 3 个列表,我想找出第一个/第二个和第二个/第三个之间的区别并打印出来。

这是我的代码:

n1 = [1,1,1,2,3] 
n2 = [1,1,1,2] # Here the 3 is not found ("3" is not present in n1 at all)
n3 = [1,1,2] # here 1 is not found (there are fewer "1"s in n3 than in n2)
for x in n1:
if x not in n2:
print x
for m in n2:
if m not in n3:
print m

但我只得到 3 个作为输出。

如何让它输出1和3?我也尝试使用 set,但它只再次打印了 3

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com