Last active
June 8, 2016 13:54
-
-
Save yellowsnow/c333cbf48bac3f77cc50e5e078fcbab5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
weighted_choices = [('Red', 3), ('Blue', 2), ('Yellow', 1), ('Green', 4)] | |
population = [val for val, cnt in weighted_choices for i in range(cnt)] | |
random.choice(population) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
villes_avec_poids = [('Tanger', 3), ('Oujda', 2), ('Boujdour', 1), ('Tinghir', 4)] | |
possibilites = [val for val, cnt in villes_avec_poids for i in range(cnt)] | |
ville = random.choice(possibilites) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment