dimanche 4 décembre 2016

how python print me each element when i use random?

I need a list of 8 elements and i want that python randomly import that elements in a list. But i need each of them elements in a list. Like this:

I need numbers of 0 to 4 in a list, but if I write:

s = []
for i in range(8):
    s.append(random.randint(0,4))
print("s:", s)

python doesn't print me each of number at least once. Python print me like that:

s = [1,0,2,2,1,0,1,3]- in this list is 4 missing but i want all 5 numbers at least once in a list.

Please help me.




Aucun commentaire:

Enregistrer un commentaire