Last active
May 10, 2016 10:02
-
-
Save davidchua/a97242da1a4d2bd3eba1185f082ba8b5 to your computer and use it in GitHub Desktop.
Chunking a list into groups of (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 chunk(l,n): | |
for i in range(0,len(l),n): | |
yield l[i:i+n] | |
list = [] # chunks | |
chunk(list, 30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment