mercredi 23 novembre 2016

How do you enter numbers into a list without any being repeated?

I am trying to make a list with the numbers 1-24 all in it in a random order, why doesn't this work?

full_list = []

x = 0
while x < 25 :
    n = randint (1,24) 
    while n in full_list:
        n = randint (1,24)
    full_list.append(n)
    x = x + 1




Aucun commentaire:

Enregistrer un commentaire