You can use the module Random to generate random values:
If you do not want repeated values:
import random
x = 5
saida = []
for _ in range(x):
saida.append(random.choice(range(100)))
print saida # [5, 75, 9, 38, 33]
Or better yet:
import random
x = 5
saida = random.sample(range(100), x)
print(saida) # [69, 47, 43, 64, 16]
If there can be repeated values:
import random
x = 5
saida = []
for _ in range(x):
saida.append(random.randint(0, 100))
print saida # [74, 12, 15, 32, 74]
Note that you can use a list comprehension for any of the above solutions:
import random
x = 5
saida = [random.randint(0, 100) for _ in range(x)]
print saida # [88, 37, 17, 27, 58]
DEMONSTRATION of the three above
I vaccinated and you went faster :p Good answer +1
– Jéf Bueno
Thank you very much! It worked perfectly!
– Danilo
You’re welcome @Danilo
– Miguel