Posted By

magicrebirth on 12/22/09


Tagged

list python list-comprehension


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

magicrebirth


Break a list into n sublists


 / Published in: Python
 

  1. mylist = range(150)
  2.  
  3. nestedlist = [mylist[start:start + 20] for start in range(0, len(mylist), 20)]

Report this snippet  

You need to login to post a comment.