Siv*_*ram 0 python for-loop exception
a = 6 item_list = [1,2,3,4,5] for items in item_list: if items == a: print("match found") else: print ("no match")
在这段代码中,我希望在完成所有迭代后只打印一次“不匹配”;不是每次迭代。如何修改代码?
ipj*_*ipj 5
改用:
a = 6 item_list = [1,2,3,4,5] if a in item_list: print("match found") else: print ("no match")
无需自己迭代列表,使用内置方法。
归档时间:
5 年,4 月 前
查看次数:
52 次
最近记录: