title: Splitting a list into N parts of approximately equal length
body: <p>What is the best way to divide a list into <em>roughly</em> equal parts? For example, if the list has 7 elements and is split it into 2 parts, we want to get 3 elements in one part, and the other should have 4 elements.</p>
  
  <p>I'm looking for something like <code>even_split(L, n)</code> that breaks <code>L</code> into <code>n</code> parts.</p>
  
  <pre><code>def chunks(L, n):
      """ Yield successive n-sized chunks from L.
      """
      for i in range(0, len(L), n):
          yield L[i:i+n]
  </code></pre>
  
  <p>The code above gives chunks of 3, rather than 3 chunks.  I could simply transpose (iterate over this and take the first element of each column, call that part one, then take the second and put it in part two, etc), but that destroys the ordering of the items.</p>