0

So I have a list, let's say list = [1,2,3,4,5,6,7,8,9,10] and I want to divide it equally between x number, in this scenario let's say 3, how can I make it so it turns into, list = [1,2,3] [3,5,6] [7,8,9,10]

or something similar, I tried dividing a list of 30 items between 25 lists and it gave me 24 single entries and the last one had 5, instead of giving 20 single items and 5 double items perse.

  • Please read the tag(s) you included. You are asking an off-topic question. See [help/on-topic]. – DavidPostill Mar 31 '20 at 14:13
  • 1
    The answer can be found on this [link](https://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks) – aesutsha Mar 31 '20 at 14:29
  • @aesutsha. I don't think that is what the OP asked for. He asked how to best split list into certain number of sublists, not how to make sublists of fixed size. Question should be re-opened. – AirSquid Mar 31 '20 at 14:37
  • @JeffH That is correct, that is actually the method I tried and it results with 24 lists with a 1 single entry and 1 list with 5 entries – Kevin Araiza Suarez Mar 31 '20 at 19:31
  • @KevinAraizaSuarez I ginned you up a solution that worked. You should be able to calculate the slice points by doing float division and using the round() function. – AirSquid Apr 02 '20 at 00:03

0 Answers0