Skip to content

Instantly share code, notes, and snippets.

@davidchua
Last active May 10, 2016 10:02
Show Gist options
  • Save davidchua/a97242da1a4d2bd3eba1185f082ba8b5 to your computer and use it in GitHub Desktop.
Save davidchua/a97242da1a4d2bd3eba1185f082ba8b5 to your computer and use it in GitHub Desktop.
Chunking a list into groups of (x)
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