17/19


#1

help a brother out
def shut_down(s):
if s == "yes"
return "shutting down"

elif:
    s == "no"
    return "shutdown aborted"

    if shut_down():
    return "sorry"

#2

I have this now

def shut_down(s):
if s == "yes":
return "shutting down"

elif s == "no":
     return "shutdown aborted"

if shut_down():
    return "sorry"

but this happens

Oops, try again. Your shut_down function should take one parameter.


#3

Do it like so,

def shut_down(state):
    if state == 'yes':
        return "Shutting Down"
    elif state == 'no':
        return "Shutdown Aborted" 
    else:
        return "Sorry"

Or you can do it like so,

def shut_down(state):
    responses = {1: "Shutting Down",
                 2: "Shutdown Aborted",
                 3: "Sorry"}
    return responses[1] if state == 'yes' else responses[2] if state == 'no' else responses[3]

I love ternary functions, they are hilariously cool. Though do not use too many or it looks like crap.


#4

Bud, You should test the shutting down conditions 'yes' or 'no'. Not the function it self. try something like below. Check the indentation before running. Hope this helps.

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


#5

thanks guys this helped me out a lot!


#7