Skip to content

Instantly share code, notes, and snippets.

@lambdaman2
Created October 1, 2012 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lambdaman2/3811596 to your computer and use it in GitHub Desktop.
Save lambdaman2/3811596 to your computer and use it in GitHub Desktop.
Python: Break a list into n sublists
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