Created
August 25, 2015 15:44
-
-
Save mikkkee/eeaffa9f0d30add11623 to your computer and use it in GitHub Desktop.
Cut list into chunks
This file contains 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
# 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