Need help with the Shutting down


#1

Something wrong with the code. Not returning as the intended value , can someone please help? The tutorial says its complete and correct but I have doubts about the logic.

def shut_down(a):
if a == "yes":
return "Shutting down"
print "shutting down"
elif a =="no":
return "Shutdown aborted"
print "shutdown aborted"
else:
return "Sorry"
print "sorry"

shut_down ("no")


#2

Delete all print statements because they have no use.
when execution hits the return statement ,it just get off from function body.
It does not execute(run) any code after return statement!

also check if your code is indented properly.

def anyfunction():
    if condition1:
        #your code
    elif condition2:
        #your code
    else:
       #yourcode

#3

which value is it returning that it shouldn't? If you want to print the returned value add a print statement before your function call


#4

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