title: What does "[w for w in word_tokens if..." mean in Python?
body: <p>I have a general question about the syntax used in Python. I am very new to programming so this might seem like a noob question, but I'm using pythons nltk, and in that there is a command which appears as follows...</p>
  <pre><code>word_tokens = word_tokenize(example_sent)
  
  filtered_sentence = [w for w in word_tokens if not w in stop_words]
  
  filtered_sentence = []
  
  for w in word_tokens:
  if w not in stop_words:
      filtered_sentence.append(w)
  </code></pre>
  <p>Is anyone able to explain the logic behind the &quot;w for w in word_tokens&quot;?
  I have seen this in several forms, so can anyone break down what is happening here in the &quot;X for X in X&quot;?</p>
  <p>Would just like some clarity on the concept used here, thanks in advance!</p>