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>Here's the snippet fixing your error:</p>

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

resultwords = [word for word in lst if word not in stopwords]
result = ' '.join(resultwords)
print result
</code></pre>

<p>Another possible solution assuming your input list and stopwords list don't care about order and duplicates:</p>

<pre><code>print " ".join(list(set(lst)-set(stopwords)))
</code></pre>

python list