I looked over Python Docs (I may have misunderstood), but I didn\'t see that there was a way to do this (look below) without calling a recursive function.
What I\'d like
Generate one random number and map it onto your desired ranges of numbers.
If you wanted to generate an integer between 1-4
or 7-10
, excluding 5
and 6
, you might:
1-8
2
to the result.The mapping becomes:
Random number: 1 2 3 4 5 6 7 8
Result: 1 2 3 4 7 8 9 10
Doing it this way, you never need to "re-roll". The above example is for integers, but it can also be applied to floats.