Skip to content
Advertisement

Python Chest Opening Odds

I’ve been trying to figure out how to recreate odds in python for a chest opening game thingy, but the random.choice isn’t really considering different odds. The goal I’m trying to achieve is set certain odds for different “rarities”, like for example having 50% probability for getting an “Uncommon”.

Code example:

JavaScript

Advertisement

Answer

My advice is to use Random choice() method since it allows you to make a list where you can specify probability for each element. https://www.w3schools.com/python/ref_random_choices.asp

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement