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

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -