This code returns a number between 0 and 2:
from random import randint
a = randint(0, 2)
print(a)
Each "option" has 33.3% frequency.
This code return a number between 0 and 2, too, but the "options" has following frequency: 0...50% 1...25% 2...25%
a = randint(0,1)
if a == 0:
print(a)
else:
a = randint(1,2)
print(a)
It's working, but if I have more options or more difficult frequencies, the code will be too long and messy. So the question is: Is there any way to make the code (shown upper) more smarter and simpler?