Stuck in 17:Review Functions


#1

Hi! I am currently stuck!

17: Review Functions.

I keep getting the following error message:
Oops, try again. Your function failed on the message yes. It returned 'yes' when it should have returned 'Shutting down'

Can anyone tell me what is wrong with my code????

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

Any help would be appreciated! Thank you!


#2

I just changed the quotes from single to double quotes.

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

#3

I just found the problem based on other discussions!

I had to remove the following line: return(s)


#4

Thanks! It worked when I removed the line...return(s).


#5

I don't think there is a difference in either single or double quotes really.

But if you look at the instruction, it says to use return but with the return and condition string in double quotation.

Good that what you did worked.


#6

There is not difference unless you mix them


#7

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