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>A list comprehension with a condition checking for membership in <code>stopwords</code>.</p>

<pre><code>print [item for item in List if item not in stopwords]
</code></pre>

<p>or <code>filter</code></p>

<pre><code>print filter(lambda item: item not in stopwords, List)
</code></pre>

<p>or <code>set</code> operations, you can refer to my answer on speed differences <a href="http://stackoverflow.com/a/38977964/6320655">here</a>.</p>

<pre><code>print list(set(List) - set(stopwords))
</code></pre>

<p><strong>Output -></strong> <code>['Noyouarenot']</code></p>

python list