0
How do I create an if elif else statement on a random number that the console creates? Python
Simply put, I am trying to make the console create a random # from 0-2. and based on that random number I plan to make an if elif else stayement. I think that means I will have to define X and set it equal to X? kind of like this X = [] or def x(): random#generator(0,2) and then use it like so if x == int(0): do a thing elif x == int(1): do a different thing else: do something else Basically I don't know what command to use to create the random number....
8 Answers
+ 2
import random
help(random)
+ 2
Try to import only the random module. Then you will need to call it like this: random.randint (0,1)
0
thank u both
0
and I love the answer for the else statement porf!
0
but I can't import a randit. in my code
0
so would I just put in import random and then random.randint (1,0)?
0
I'm just not sure what that would look like :)