python - Function messed up? -
python - Function messed up? -
why function not working? seems n never equal 2.
def option2(): n = random.randrange(2) if n==2: print ("you find mysterious black box , hear noises coming within it.") print ("what do?") print ("1. open it.") print ("2. investigate enviroment surrouding it.") print ("3. smell begrudgingly.")
random.randrange() works built-in range(); end value not included. random.randrange(2) ever produces 0 or 1.
from random.randrange() documentation:
this equivalent choice(range(start, stop, step)), doesn’t build range object.
and range(2) produces:
>>> range(2) [0, 1] python
Comments
Post a Comment