title: How can I use a list comprehension to extend a list in python?
body: <p>I'm not experienced in Python, and I often write code that (simplified) looks like this:</p>
  
  <pre><code>accumulationList = []
  for x in originalList:
      y = doSomething(x)
      accumulationList.append(y)
  return accumulationList
  </code></pre>
  
  <p>Then after my test passes, I refactor to </p>
  
  <pre><code>return [doSomething(x) for x in originalList]
  </code></pre>
  
  <p>But suppose it turns out a little different, and my loop looks like this:</p>
  
  <pre><code>accumulationList = []
  for x in originalList:
      y = doSomething(x)
      accumulationList.extend(y)
  return accumulationList
  </code></pre>
  
  <p>where the <code>doSomething</code> list returns a list. What is the most Pythonic way to accomplish this? Obviously, the previous list comprehension would give a list of lists.</p>