My question is about random.choice
function. As we know, when we run random.choice(['apple','banana'])
, it will return either 'apple'
or 'banana'
with equal probabilities, what if I want to return biased result, for example, rerurn 'apple'
with 0.9 probability and 'banana'
with 0.1 probability? How to implement this?