This question already has an answer here:
- A weighted version of random.choice 23 answers
I have a list with these elements:
list = ["A", "B", "C", "D", "E"]
If i use the random module ex: random.choice (list)
it will return a random letter 20 % of the times (notion of probability). However imagine i want to return the letter A more times than the rest of the letters . Imagine the probability of returning the letter A is 60 % and the rest of the letters is 10%.
How can i simulate this situation ?
Aucun commentaire:
Enregistrer un commentaire