removing words from a list after splitting the words :Python
<p>I have a list </p>

<pre><code>List = ['iamcool', 'Noyouarenot'] 
stopwords=['iamcool']
</code></pre>

<p>What I want to do is to remove stowprds from my list. I am trying to acheive this with following script </p>

<pre><code>query1=List.split()
resultwords  = [word for word in query1 if word not in stopwords]
result = ' '.join(resultwords)
return result
</code></pre>

<p>So my result should be </p>

<pre><code>result =['Noyouarenot']
</code></pre>

<p>I am receiving an error </p>

<pre><code>AttributeError: 'list' object has no attribute 'split'
</code></pre>

<p>which is right also, what small thing I am missing, please help. I appreciate every help. </p>

<p>It should be <code>result=[i for i in Mylist if i not in stopword]</code></p>

<p>I think you should read the document like <a href="https://docs.python.org/2/tutorial/datastructures.html" rel="nofollow">this</a>.It will help you learn Python.</p>

<p>By the way,I know something about NLP.<br>
I think the input should be a sentence,like </p>

<pre><code>input="I am Jack"
</code></pre>

<p>And you can use the <code>split</code> method ,<code>input.split()</code> you will get <code>["I","am","Jack"]</code>.
Then use loop to determine whether it is a stopword.</p>

<pre><code>stopword=["am","which"]

result=[i for i in input.split() if i not in stopword]
</code></pre>

<p><a href="https://docs.python.org/2/library/stdtypes.html#str.split" rel="nofollow">str.split()</a></p>

<p>Hope this helps.</p>

python list