17: Review Functions


#1

def shut_down(s):
return s

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

I get this error message: Your function failed on the message yes. It returned 'yes' when it should have returned 'Shutting down'

Hope someone can help


#2

Hi Slumpe,

Right below def shut_down(s): did you include return s or is that a typo?

It's the only thing I'm seeing wrong with this code.


#3

I did.
It work when I removed that line.

Thanks for the help!


#4

Great to hear!

Good luck with coding and keep pushing forward!


#5

why shouldn't we include return s, when and where is return exactly used i.e when is the return function boolean(true,false) and when do we return arguments


#6

Hey lloan, can you please me solve my error for same problem
def shut_down(s):
return s

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

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

else:
return "Sorry"

shut_down("yes")

Its showing me error 'return' outside function


#7

well 1st you dont really need those paranthesis

second cancel the return s

third this line

shut_down("yes")
dosent need to be there

thats what i see wrong in your code


#8

My code is

def shut_down(s):

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

I keep getting the error: File "python", line 3
if s == "yes":
^
IndentationError: expected an indented block

what am I doing wrong?


#9

It's as the error message says. I cant give you an accurate answer as the code is not formatted.

Check your indentations.


#10

def shut_down(s) :
if s == "yes" :
return "Hutting down"
elif s == "no" :
return "Shutdown aborted"
else :
return "Sorry"
ans = raw_input("Enter your response")
shut_down(ans)

from the above code , i am not getting the output.....why ??


#11

in your function argument use s not ans
def shout_down (s) not dif shout_down(ans).
when returning from function you have to use what you function name and argument is.


#12