给定一个int数组长度2,如果它包含2或3,则返回True。我不能使用循环。大多数测试用例都可以工作,除了:
has23([4, 5]) --> False (my code returns True)
has23([7, 7]) --> False (my code returns True)
has23([9, 5]) --> False (my code returns True)
我的代码:
def has23(nums):
if 2 or 3 in nums[0:1]:
return True
else:
return False