I've been trying to create randoms lists of 15 numbers picking only a single one from each list available (15 lists) and without repeat any number.
The code as follows did that, but it is limited to only two different lists. I'd like to get rid of this limitation.
import random
n1 = list(range(1, 5))
n2 = list(range(2, 5))
n3 = list(range(3,6))
n4 = list(range(5,8))
n5 = list(range(6,10))
n6 = list(range(8,12))
n7 = list(range(10,13))
n8 = list(range(11,15))
n9 = list(range(13,17))
n10 = list(range(14,18))
n11 = list(range(16,20))
n12 = list(range(18,21))
n13 = list(range(20,23))
n14 = list(range(22,24))
n15 = list(range(23,25))
for i in range(10):
lista = random.sample(list(zip(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15)),1)
print(lista)
Aucun commentaire:
Enregistrer un commentaire