About the randint function
I was wondering if there was a way to eliminate options from a pool of random numbers. For instance, if I had variable = randint(1,10) but I didnt want it to pick say the number nine, if theres a way of skipping that number.
You can do this a couple of ways
1, You can use
It returns a randomly chosen element from a list
import random arr=[1, 3, 4, 6, 7, 10] print(random.choice(arr))
2, You can just reject it
disallowed=[9, 3, 6] num=3 while num in disallowed: num=random.randint(1, 10)