"Review: Functions"


#1


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


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


#2

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 =


#3
 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


#4

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

if s=="yes":
    return "shutting down"

#5
 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


#6
 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


#7

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


#8

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


#9

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"


#10

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


#11

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


#13

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.


#15

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"


#16

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"


#17

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


#18

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!


#20

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?


#21

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


#22

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:


#23

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