samedi 7 décembre 2019

How to create multiple lists in which the next list picks up where the last list left off?

Having a hard time figuring out a homework question where i need to create lists in succession and the next list has to pick up where the last left off. For example given the value x = 3 y = 5. I would like a list returned to look like [[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15]]. So essentially there are 'x' number of lists going up in increasing intervals of 'y' while picking up where the last list left off.The list will always start off at 1 This is what I have so far but I know it's far from what I need.

 def test(y):

  initial_list = list(range(1,y+1))

  return initial_list

I need to have x as a condition for the function as well.

Aucun commentaire:

Enregistrer un commentaire