0

How to built a function where the parameter ecpect an integer in a list. Should look like this:

Input: [3,1,5] Output [[1,2,3], [1], [1,2,3,4,5]]

20th May 2017, 9:58 AM
lars
4 Answers
+ 3
you can define the parameters as you like however is convenient for you i used a string of numbers seperated by a comma ( , ) so i could split them and then build each array
20th May 2017, 10:38 AM
Burey
Burey - avatar
0
Thank you! but why is there an error, when I write: def f (vals): vals = [3,1,5] vals= vals.split (',') valsList=[list (range (1,int (r)+1) for r in vals] print (valsList) f () #?
20th May 2017, 10:21 AM
lars
0
Ok I got it, but is it possible that the parameter must be a list with integers?
20th May 2017, 10:28 AM
lars