title: When to use a list comprehension vs a for loop
body: <p>Is there a general rule for when a list comprehension is preferred over a <code>for</code> loop? For example:</p>
  
  <p>A single for loop is great when converted to a comprehension:</p>
  
  <pre><code>l = []
  for word in sentence:
      l.append(word)
  
  # [word for word in sentence]
  </code></pre>
  
  <p>A double one might be too:</p>
  
  <pre><code>l = []
  for word in sentence:
      for letter in word:
          l.append(letter)
  
  # [letter for word in sentence for letter in word]
  </code></pre>
  
  <p>However, I think the readability gets pretty poor after that. For example, with <code>if</code>s:</p>
  
  <pre><code>l = []
  for word in sentence:
      if word.startswith('u'):
          for letter in word:
              if letter in ('a', 'b', 'c', 'o'):
                  l.append(letter)
  
  # [letter for word in sentence if word.startswith('u') for letter in word if letter in ('a', 'b', 'c', 'o')]
  </code></pre>
  
  <p>Is there a suggestion for the complexity of a <code>for</code> loop pattern where it would be worse trying to put it into a list comprehension?</p>