This question already has an answer here:
- A weighted version of random.choice 20 answers
Let's say i have a dict
{'option one': 5.0, 'option two': 5.0, 'option three': 10.0}
How can i randomly select a key based on the probabilities above (ie. option one and two will have a 25% of being chosen. Option 3 would have a 50% chance of being chosen)
Aucun commentaire:
Enregistrer un commentaire