I have a list of positive integers like this:
mainlist=[0,1,2,3,...,3999]
And out of it I want to generate a list of 50 lists, where each sublist has increasing length (10, 20, 30,..., 500). Each sublist element is a random.sample()
selection of values from mainlist
.
This is my attempt (coming from here):
import random
mainlist=[i for i in range(4000)]
listoflists=[random.sample(mainlist, l) for l in range(10, 510, 10)]
However this gives me an error:
TypeError: random_sample() takes at most 1 positional argument (2 given)
Why is that so? I am using Python 2.7.11 32-bit with Jupyter on Windows 8.1
Aucun commentaire:
Enregistrer un commentaire