<分区>
我希望能够输入一个值并检查它是否在列表中,如果它在列表中则运行所需程序的其余部分。
a=input('enter value')
b=(1,2,3,4)
c=(5,6,7,8,9)
if a is in b:
print 'enter in code thats wanted'
<分区>
我希望能够输入一个值并检查它是否在列表中,如果它在列表中则运行所需程序的其余部分。
a=input('enter value')
b=(1,2,3,4)
c=(5,6,7,8,9)
if a is in b:
print 'enter in code thats wanted'
最佳答案
你自己写的几乎是正确的,而不是 -
if a is in b:
应该是——
if a in b:
关于python - 如何检查输入是否在 python 列表中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11185781/