2

Possible Duplicate:
How do you split a list into evenly sized chunks in Python?

I have a list more than 500 elements long.

I want to divide it into 5 lists, each of 100 elements.

mylist = [1......................700]
if len(mylist) > 100:
       newlist1 = mylist[0:100]
       someothelist = mylist[100:]
       if len(someotherlist) > 100:
           newlist2 = someotherlist[0:100]
           someotherlist2 = mylist[100:]

What's the best way to implement it using iteration?

Community
  • 1
  • 1
user102724
  • 89
  • 4
  • 9
  • Duplicate: http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python/312644 – S.Lott May 29 '09 at 10:19
  • This is the same question: http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python/312644 – Wim Leers May 29 '09 at 09:33

0 Answers0