Review functions


#1


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

Oops, try again. Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Your code threw the following error: invalid syntax (python, line 1)


what am I doing wrong?
def shut_down(s)
return (s)
if (s) == 'yes':
return "shutting down..."
elif (s) =='no':
return "shutdown aborted"
else:
return "sorry"


#2

First, make sure you indented your code properly (indentation is really important in Python!!). Should look like this:

def shut_down(s) 
    return (s) 
    if (s) == 'yes':
        return "shutting down..." 
    elif (s) =='no':
        return "shutdown aborted"
    else:
        return "sorry"

Secondly, you missed a colon : after def shut_down(s).

Lastly, you don't need return(s) as it will just return your input (which is not what the lesson wants). Return ends your function so all your if statements will get skipped. Remove it.

ALSO, they want you to return "shutting down" when s == 'yes' not "shutting down...". Remove the ellipses.


#3

I did a lot of mistakes, for example: (forgot ":" 3times, than forgot spaces, than to allign properly codes)
Sometimes is very frustrating, but, I hope, once is learned-than is good! :slight_smile:

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


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.