So I have a function called start() and it has multiple if statements and I want all of them to run.

def start():
    print """You have just woken up from a very long nap.
    You find yourself in a dimly lit cave.
    There is a patch of light in the far distance above you. 
    There is a torch on the wall lighting the immediate area.
    There are dark passage ways in all directions."""
    decision = raw_input(prompt)
    if decision == "take torch":
        print "You took the torch."
    # if you don't take the torch, you can't go anywhere
    elif decision == "north" or "east" or "west" or "south" and not 'torch' in inventory:
        print "It is too dark to see in the tunnel."
    # python skips this.
    if decision == "north" and 'torch' in inventory:

Is there a way to make python run through that if statement even if the first statement it encounters is true?

EDIT: Okay, that was dumb. I should've put another raw_input to take in the user's input.

Edited by ohblahitsme: I realized what I did wrong.

5 Years
Discussion Span
Last Post by woooee

This statement will always yield True

elif decision == "north" or "east" or "west"
#It breaks down to 
    elif decision == "north" 
         or "east" 
         or "west"

and both "east" and "west" are not empty strings so either will evaluate to True. Instead use

elif decision in ["north", "east", "west"]:
Votes + Comments
That was really helpful!
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.