Hi, i dont whats wrong with my code.please help


#1

def shut_down(s):
return s

if yes():
    shut_down("Shutting down")
elif no():
    shut_down("Shutdown aborted")
else :
    shut_down("sorry")

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


#2

Try thinking of it this way...if you are entering in a value called s.
you now want to check s against 'yes' or 'no'

so try somethng like this

if s == 'yes':
return "Shutting down"
then follow this idea using your elif for comparing to 'no'
and if there is nothing entered return 'sorry'

and make sure to indent correctly....good luck


#3

Hi i saw your comment, i em stuck on this lesson for long
so if you solved it , your help would be great
here is code i wrote , i think it is according yours suggestion but it still do not work:(


#4

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


#5

Hi i finaly solve it

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

take care of intedning of lines


#6

Great job sticking with it and not giving up....thats the best way to learn


#7

I have a problem with the same code.

It returns a meaningless error message. Is this a joke?


#8

Ok, I saw my mistake. I: wrote "shot" instead of "shut". :stuck_out_tongue_winking_eye:
We wouldn't really want to do that. :laughing:


#9

@violetanka after changing this do your programme worked or not if yes please tell me


#10

Yes, it worked. But you should first try to solve it yourself and try to find your mistakes rather than looking at the solution as soon as you get the error message. Otherwise you won't learn much. If you have already tried, it is OK. :smiley:


#11

thank u all. It worked.
@billmac1701 thank you for your help.