mardi 16 avril 2019

How to randomly select a key from a dictionary based on it's float value [duplicate]

This question already has an answer here:

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