17.Review: Functions syntax error


#1



https://www.codecademy.com/en/courses/python-beginner-c7VZg/4/1?curriculum_id=4f89dab3d788890003000096#

So I keep getting this error every time I save and submit and I don't know what I have done wrong.
Error message:
File "python", line 5
elif s == "no":
^
SyntaxError: invalid syntax

My code:
def shut_down(s):

if s == "yes":
    return "Shutting down"
    elif s == "no":
        return "Shutting aborted"
        else:
            return "Sorry"


Replace this line with your code.


#2

Your if, else and elif statements should have the same indentation.


#3

Hello!

First, do the indenting!

if s == "yes":
        return "Shutting down"`
elif s == "no":
        return "Shutting aborted"
else:
        return "Sorry"

Now it will still have an error message. You put "Shutting abort" It was suppose to be "Shutdown aborted" Your final code should look like this:

def shut_down(s):
    if s == "yes":
        return "Shutting down"
    elif s == "no":
        return "Shutdown aborted"
    else:
        return "Sorry"

#4

wow, so simple, i was trying to use raw_input to get the answer and having no success. TY


#6

this is the correct answer for the exercise 17. you have to put the correct indenting for line if, elif and else shown as above.


#7

Hey, no problem! Still learning python and I love helping people!


#8

def shut_down(s):
if s == "yes":
return "Shutting down"

elif s == "no":
return "Shutdown aborted"

else:
return "Sorry"

^This is my exact code.I cant find any diff b/w our codes.can you help me out?Thanks


#9
def shut_down(s):
    if s == "yes":
        return "Shutting down"
    elif s == "no":
        return "Shutdown aborted"
    else:
        return "Sorry"

Are you sure that you did the indenting correctly?

Also please send me your error message too. :slight_smile: