Skip to content

Instantly share code, notes, and snippets.

@kai5263499
Created September 28, 2017 11:08
Show Gist options
  • Save kai5263499/452a000cc3e6ba40e48617a4fd49272e to your computer and use it in GitHub Desktop.
Save kai5263499/452a000cc3e6ba40e48617a4fd49272e to your computer and use it in GitHub Desktop.
Split a list into equally sized chunks
# 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