mercredi 3 juin 2020

Can I have k as a random number in random.choices()?

I want to make a randomized list ,and random.choices does that. An example is

 list = [1,2, 3, 4, 5, 6]

numbers = random.choices(list, k=2)

print("2 random numbers", numbers)

In this case, it will print 2 random numbers from the list because k is 2 ,but I want k to be a random number in a set range as well ,so a different amount of items on the list would be printed. How do I do that? Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire