graded randomness

Chris Angelico rosuav at
Fri Dec 28 08:32:42 EST 2018

On Sat, Dec 29, 2018 at 12:28 AM Abdur-Rahmaan Janhangeer
<arj.python at> wrote:
> woops @ben me too i got that solution but i'm searching for a neater answer.
> let us say i'm using it over new data, 1 million data of red blue green can
> be saved by just dealing with the probabilities ^^_

Assuming you're on Python 3.6 or newer, you should be able to use
random.choices() for this.

>>> random.choices("spam", [10, 1, 3, 2])

You can get any of the four letters back, but you're more likely to
get 's' than anything else. Is that the sort of thing you're after?


More information about the Python-list mailing list