Created
October 1, 2012 12:49
-
-
Save lambdaman2/3811596 to your computer and use it in GitHub Desktop.
Python: Break a list into n sublists
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
mylist = range(150) | |
nestedlist = [mylist[start:start + 20] for start in range(0, len(mylist), 20)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment