Generate 100 lists of length from 10 to 10000. The elements of the list should be in the range [0,1). Python
import random
num_lists = 100
min_length = 10
max_length = 10000
step = 10
lists = []
for i in range(num_lists):
# losowa długość listy
length = random.randrange(min_length, max_length+1, step)
# generowanie losowej listy z wartościami od 0 do 1
lst = [random(0, 1) for _ in range(length)]
lists.append(lst)
print(lst)
But the code gives one long list. What should I do? Please help
Aucun commentaire:
Enregistrer un commentaire