我有一个清单


  A = [“贷款”,“ Mercedez”,“布加迪”,“ a4”,“王牌”,“美国”,“选举”,
  “总统”,“星系”,“ 7s”,“佳能”,“ macbook”,“ beiber”,
  “蜘蛛侠”,“奇迹”,“铁人”]





  B = [“贷款”,“网络”,“华盛顿”,“王牌”,“佳能”,“伦敦”]


当我做一些事情以便从B中获取不存在的单词时
列出A

for i in A:
    for j in B:
        if j not in i:
            print (j)


它给出的循环周期为:-

network
washington
trump
canon
london
loans
network
washington
trump
canon
london
loans
network
washington
trump
canon
london
loans
network
washington
trump
canon
london
.......
.......
.......


为什么这样?我要退货

network
washington
london

最佳答案

for i in B:
    if i not in A:
        print (i)

07-24 15:49