我知道这个问题是基本的,但我需要一些适当的逻辑解释,请原谅我的无知。我定义了一个函数,如果数字 2 或 3 在列表中,则返回 True,否则返回 False。它适用于 2 或 3。但也适用于其他人......我只是不明白为什么。这是我的功能的一瞥:
def has23(nums):
if (2 or 3 in nums):
return True
else:
return False
# has23([4,5])
# True # Why
Helenr
幕布斯6054654
慕田峪4524236
相关分类