Last active
November 27, 2017 23:46
-
-
Save rhemz/7cb9dd5125a45e20467e9f9cb15d4180 to your computer and use it in GitHub Desktop.
python - split iterable into chunks of size X
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 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