Created
September 28, 2017 11:08
-
-
Save kai5263499/452a000cc3e6ba40e48617a4fd49272e to your computer and use it in GitHub Desktop.
Split a list into equally sized chunks
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
# from https://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks | |
def chunks(l, n): | |
"""Yield successive n-sized chunks from l.""" | |
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