title: One line for loop to add elements to a list in Python
body: <p>I am trying to remove stop words (from nltk) from my data set but not sure why the one line query is not working: </p>
  
  <pre><code>filtered_words = [word if word not in stop_words for word in words]
  </code></pre>
  
  <p>This is what I need to do:</p>
  
  <pre><code>filtered_words = []
  for word in words:
      if word not in stop_words:
          filtered_words.append(word)
  </code></pre>