Skip to content

Instantly share code, notes, and snippets.

@rhemz
Last active November 27, 2017 23:46
Show Gist options
  • Save rhemz/7cb9dd5125a45e20467e9f9cb15d4180 to your computer and use it in GitHub Desktop.
Save rhemz/7cb9dd5125a45e20467e9f9cb15d4180 to your computer and use it in GitHub Desktop.
python - split iterable into chunks of size X
def chunkify(iterable, size):
return [iterable[x:x + size] for x in xrange(0, len(iterable), size)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment