Break a list into n sublists


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. mylist = range(150)
  2.  
  3. nestedlist = [mylist[start:start + 20] for start in range(0, len(mylist), 20)]

Report this snippet


Comments


You need to login to view comments.