Python列表'in'语句无法正常工作

Cha*_*ndo 2 python list

我尝试使用'in'函数来检查列表中的某些值是否可用.但它无法正常工作.

from nltk.tokenize import word_tokenize

x ='what are bad'
a= word_tokenize(x)[0]
qestion = ['what,why,how,are,am,should']

if a in qestion:
 print 'question'
else:
 print 'not a question'
Run Code Online (Sandbox Code Playgroud)

我找不到原因.任何人都可以帮我解决这个问题.

e4c*_*4c5 6

以下肯定是一个列表,但我不认为这是你正在寻找的列表.

 qestion = ['what,why,how,are,am,should']
Run Code Online (Sandbox Code Playgroud)

我想你想要的是什么

question = 'what,why,how,are,am,should'.split(',')
Run Code Online (Sandbox Code Playgroud)

哪个产生

['what', 'why', 'how', 'are', 'am', 'should']
Run Code Online (Sandbox Code Playgroud)

哪个更有可能在y条件下完全填满你的IF x.