On Sat, Dec 29, 2018 at 12:28 AM Abdur-Rahmaan Janhangeer <arj.pyt...@gmail.com> 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. https://docs.python.org/3/library/random.html#random.choices >>> random.choices("spam", [10, 1, 3, 2]) ['a'] 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? ChrisA -- https://mail.python.org/mailman/listinfo/python-list