So I have a variable that creates a random number between 0 and 10, however, I would not like the random number created to be 5. How do I go about adding exceptions to random.randint in Python? What I have below is not doing this:
number = random.randint(0, 10) !=5
This is only returning True or False based on whether the random number equals 5 or not... how do I fix this?
You can do
number = random.randint(0,10)
while number == 5:
number = random.randint(0,10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With