Skip to content

Instantly share code, notes, and snippets.

@mikkkee
Created August 25, 2015 15:44
Show Gist options
  • Save mikkkee/eeaffa9f0d30add11623 to your computer and use it in GitHub Desktop.
Save mikkkee/eeaffa9f0d30add11623 to your computer and use it in GitHub Desktop.
Cut list into chunks
# Cut list into chunks.
def chunk(to_cut,piece_number):
'''
Cut list into equalily distributed pieces.
'''
piece_len = len(to_cut)/piece_number
for i in xrange(0,len(to_cut),piece_len):
yield to_cut[i:i+piece_len]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment