alex_dragon
alex_dragon

Reputation: 11

Error : keeps looping

def beg():
    if race == "orc":
       print ("You come to the border of the valley but the path splits into two seperate paths one going east and the other going west, there is no indication of which one goes where but you figure you will go one way.")
       print("Your options are: ")
       print("1. left")
       print("2. right")
       time.sleep(10)
       direction1 = input("You decicde to go: ")
       if direction1 == "left":
            print ("You decide to go left towards the snowy forest in which the snow elves live")
       if direction1 == "right":
            print ("You decide to go right towards the desert which is famous of the amount of bandits that are found there.")
       else:
            print ("Please pick one of the listed options")
            beg()

Basically the problem I get is that when the code runs and you choose right it works and prints the text but when you pick left it just keeps looping beg()

Upvotes: 0

Views: 37

Answers (1)

Tom Karzes
Tom Karzes

Reputation: 24052

You forgot to use elif for the "right" case, so instead of a single chained if as you intended, you have two independent if statement, the second of which has an else. Just change the "right" test to:

elif direction1 == "right":

That way you'll skip the else if it's "left".

Upvotes: 1

Related Questions