Review: functions


#1

this is my code:

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

what is wrong


#2

Yes isn't defined.

No isn't defined.

Missing end quote.


#3

just like cadecodes said. What you are doing by that is calling a variable that isnt defined. Also, you are missing "" and : colon goes after every if, elif, and else statements. Try adding this....

if s == "yes":

and repeat with the other lines.


#4

oh thanks but im off that one now should have posted that earlier sorry
:smirk:


#5

here is correct way to declare this function
def shut_down(s):
if s == 'Yes':
return s ,'shutting down'
elif s == 'no':
return s, 'aborted'
else:
return s, 'sorry'


#6

Why is this answer not passing?

s = ""

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

The answer that does pass seems a bit strange to me.

Also, would s = "" be better off inside the function as to eliminate global variables? Is that a python thing?