Created
June 19, 2015 15:36
-
-
Save studiotomi/d25e7dbe42a6019fdc08 to your computer and use it in GitHub Desktop.
Work on Chunks of an array
This file contains hidden or 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(l, n): | |
""" Yield successive n-sized chunks from l. | |
http://stackoverflow.com/a/312464/1572077 | |
""" | |
for i in xrange(0, len(l), n): | |
yield l[i:i+n] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment