Created
January 31, 2013 01:00
-
-
Save moshekaplan/4678925 to your computer and use it in GitHub Desktop.
Splits a list into n-sized chunks From http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python/312464#312464
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def chunks(chunkable, n): | |
""" Yield successive n-sized chunks from l. | |
""" | |
for i in xrange(0, len(chunkable), n): | |
yield chunkable[i:i+n] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment