+ 2

How to get more than one random choice from a list.

17th Aug 2020, 3:32 PM
Amit Kumar
Amit Kumar - avatar
4 Answers
+ 2
Amit Kumar Random has a specific method for this type of stuff. It is called sample() to choose from a specified population. Demo: import random a = [*range(11)] b = random.sample(a,3) print(b) Output: You get 3 random numbers between the range of 1 and 10. Happy Coding 😀
17th Aug 2020, 4:28 PM
Tomiwa Joseph
Tomiwa Joseph - avatar
+ 1
What is k?
17th Aug 2020, 3:46 PM
Amit Kumar
Amit Kumar - avatar
+ 1
Amit Kumar k represents how many times to take a random item from a list.
17th Aug 2020, 3:52 PM
Seb TheS
Seb TheS - avatar
+ 1
Ohh okk thank you
17th Aug 2020, 3:55 PM
Amit Kumar
Amit Kumar - avatar