numbers = (1,2,3,4)
if (5,6) not in numbers:
print(“try again”)
elif (5,6) == numbers:
print(“good job”)
它只会说第一个if语句,没有别的...我该如何解决这个问题。
if (5,6) in numbers
:不检查5
或6
是否在列表中;它检查tuple (5,6)
是否在列表中,不是。
if 5 in numbers or 6 in numbers:
或
if any(x in numbers for x in (5, 6)):
这是一个包含元组(5, 6)
的列表:
[1, 2, 3, 4, (5, 6)]
这不是:
[1, 2, 3, 4, 5, 6]
Numbers = (1,2,3,4)
if 5 not in Numbers and 6 not in Numbers:
print("try again")
else:
print("good job")