If you want to get a list of random elements from a specific list, use random.choices
. This method also allows you to weigh the possibility for each value with the weights
parameter.
In the code above, I use random.choices
to get a list of 10 random values. 0 is two times more likely to be selected than 1 and is ten times more likely to be selected than 2.