lundi 24 février 2020

Generate random number with a loop

I plan to generate a list of random numbers in a certain way as bellow:

list1 = []
rand = random.randint(1, 10)
for i in range (10):
   list1.append(rand)
list1

but the result is a list of repeating of a same number as bellow:

[8, 8, 8, 8, 8, 8, 8, 8, 8, 8]



Aucun commentaire:

Enregistrer un commentaire