Mar-07-2020, 03:28 PM
(Mar-07-2020, 04:38 AM)jefsummers Wrote: Two questions - are you looking for random integers, or random floats? Can numbers be repeated?
So random() is just a placeholder, in my program it is an object that creates different instances. Of course I don't want to copy 1 object 10 times but create 10 different instances of it.
(Mar-07-2020, 08:21 AM)scidam Wrote:Yes getting rid of the unused variable is nice, thanks!(Mar-07-2020, 01:32 AM)medatib531 Wrote: I was looking to make it more elegant (e.g. without using variable i).If you are looking for a way to do this without declaring an auxiliary variable, you can use map, e.g.
list(map(lambda x: random(), range(10)))