splitting a list into n groups

Rajarshi Guha rajarshi at presidency.com
Wed Oct 8 13:42:19 EDT 2003


Hi,
  is there an efficient (pythonic) way in which I could split a list into
say 5 groups? By split I mean the the first x members would be one group,
the next x members another group and so on 5 times. (Obviously x =
lengthof list/5)

I have done this by a simple for loop and using indexes into the list.
But it does'nt seemm very elegant

Thanks,




More information about the Python-list mailing list