Skip to content

Instantly share code, notes, and snippets.

@eirenik0
Created June 15, 2015 16:24
Show Gist options
  • Save eirenik0/4cb07b2a090e0afab0e0 to your computer and use it in GitHub Desktop.
Save eirenik0/4cb07b2a090e0afab0e0 to your computer and use it in GitHub Desktop.
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