"Review: Functions"

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

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

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>

```python

def shut_down(s = “yes”):
return “shutting down”
elif (s = “no”):
return “shutdown aborted”
else:
return “sorry”

<do not remove the three backticks above>
1 Like

Hey
You forgot the if condition , and you have to indentat elif , else at the same level of if statement
also why did you intialise your function by “yes”

if you wanna verify eqaulity of two things in python we use == not =

1 Like
 Here is my code:

def if shut_down(s):
return “shutting down”
elif (s == “no”):
return “shutdown aborted”
else:
return “sorry”

It still doesn’t run correctly. Please advise.

Thanks!

Ian Michael Jones

1 Like

why did you add if between def and shut_dow , you should add if statement like this

if s=="yes":
    return "shutting down"
 Here is my code:

if s==“yes”:
return “shutting down”
elif s==“no”:
return “shutdown aborted”
else:
return “sorry”

It still doesn’t run correctly. Please advise.

Thanks!

Ian Michael Jones

 My code ran correctly.  Thanks in advance for all of your help.  Here is my code that ran correctly.:

def shut_down(s):
if s==“yes”:
return “shutting down”
elif s==“no”:
return “shutdown aborted”
else:
return “sorry”

Sincerely,

Ian Michael Jones

2 Likes

i did the same thing but you forgot parenthesis around s == “no” and s == “yes” so its if(s==“yes”): not if s == “yes”:

1 Like

No , it’s the same if we add thos parenthesis or no !!

This code requires proper indentation. Below is my code which ran properly:

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

why is there no return s between def shut_down(s) and the if statement

Why there is no return statement between def and if ?
If i ran your code it shows the error.

File “python”, line 3
return “shutting down”
^
IndentationError: expected an indented block

you need to indent the return statements
if s==“yes”:
return “shutting down”
elif s==“no”:
return “shutdown aborted”
else:
return “sorry”
this is the correct syntax.

please i have NO idea what is wrong but it keeps asking me if i created a function called shut_down. i checked if i used the correct capitalization, i checked if i had done the brackets, and i do NOT see what went wrong. please help!

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

Hi Shubham,

Try running the following code. I faced a lot of indentation errors just because of extra spaces
def shut_down(s):
if s==“yes”:
return(“shutting down”)
elif s==“no”:
return(“shutdown aborted”)
else:
return “Sorry”

Thanks for the help.Code is correct,only you need to add space before if statement.

Why is it that for most of the codecademy exercises, we can’t view output that pertains to the code we’ve written? For this Review: Functions exercise, I’d like to see output that says “Shutting Down” or “Shutdown aborted”, rather than “None” and an indication that I can move on to the next exercise!

1 Like

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

i typed this. it shows that I haven’t define the shut_down function!!! how to correct this?

my code is work
def shut_down(s):
if s==“yes”:
return(“shutting down”)
elif s==“no”:
return(“shutdown aborted”)
else:
return “Sorry”

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

This is what worked for me… I still have to get used to the strict indentation of this language! :pensive:

Thank you friend.It worked for me after a lot of time trying to solve.I realized I forgot to add the parenthesis after if statement