Is it possible to create a variable with a random number except for one number that is stored in a variable?
For example:
import random
x = raw_input("Number: ")
y = random.randint(1,6)
So the variable x could never be y
I would suggest you to use random.choice form the list of numbers sans your number of choice
import random
x = raw_input("Number: ")
y = random.choice(range(1, x) + range(x+1, 6))
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