Can someone help me not make the code terminate whenever i input "right" [closed]

3 weeks ago 16
ARTICLE AD BOX

The problem you are having is because you have not nested the if statements, so the execution sequence is not correct. Let's see how to do it:

print ("you awaken in a dark room") print ("you look to your left, a sword is placed next to your side") print ("do you pick up the sword?") choice = input("> ").lower() if choice == "yes": print ("You pick up the sword") print ("With sword in hand you walk down the tunnel, you are confronted with the choice of turning left or right") choice = input("> ").lower() if choice == "left": print ("you turn left and face a goblin") print ("Do you attack?") choice = input("> ").lower() if choice == "yes": print ("You attack the goblin and the goblin dies by your blade ") elif choice == "no": print ("the goblin strikes your torso, causing a large gash. This weakens you") elif choice == 'right': choice = input('> ').lower() print ("you reach a cavern with a shield, do you pick it up?") if choice == 'yes': print ("you pick up the shield, its weight comfortable on your arm and you prepare yourself for the journey ahead") elif choice == 'No': print ('you ignore the shield and carry on your voyage')

Think of it like climbing a tree: when you move along a branch, you can only access its sub-branches.

Read Entire Article