mercredi 9 juin 2021

Why does Python give me Syntax error when running IF statement when I already indented? [closed]

I am doing the 35th game design exercise in Learn Python the hard way. When running the if statement, I encountered a syntax error in my second elif statement. I have tried to indent the block but it doesn't work out. Note: "happy" and "dead" is the function I created earlier in the script. Here is a part of the code where the error occurs:

def rocky_road():
    print "It's a rocky path. You saw an enormous dog sleeping in the middle of the road. What are you gonna do?"
    print "1: You shouted shooed the dog away."
    print "2: You gently petted him and gave him a treat."
    print "3: You found a different path to go."
    
    your_option = raw_input("> ")
    
    if your_option == "1":
        dead("The dog ate your head off.")
    elif your_option == "2":
        happy("The dog happily purred and guided you to the exit."
    elif your_option == "3":
        print "Oh no. You got lost. You wandered elsewhere and got back to the start."
        start()
    else: 
        print "You have three available options. Choose one =.="
rocky_road()

Aucun commentaire:

Enregistrer un commentaire