¿que esta mal? / what is wrong?


ES: porque esta mal mi codigo?, estoy en la parte 20 de la unidad 4 leccion:Funciones
no entiendo porque esta mal, gracias por leer
EN: so, why is my code wrong?, im on part 20 of unit 4 lesson: Functions, i just dont get why is not working, thanks for reading

def apagado(s):
    if s == "si" or s == "SI" or s == "Si":
        return "Apagando..."
    elif s == "no" or s == "NO" or s == "No":
        return "¡Apagado cancelado!"
        return "Lo siento, no te entendi"


Hello, @eggbert21!
Your code seems to be alright. Could you tell me what's the error message?


its in spanish hehehe, in english i think it would be something like this:
it seems that the input data that aren't si/no are not giving the result 'Lo siento, no te entendí.'

nevertheless here is the original:
¡Uy! Probá otra vez.
Parece que los datos de entrada que no son si/no, no dan como resultado 'Lo siento, no te entendí.'

now for the extra mile hahahaha
the problem is the following:
write a function apagado, that takes a parameter lets call it s for string, the function must use return to return "Apagando..." when it gets the arguments "si", "Si" or "SI" and "¡Apagando cancelado!" when it receives the arguments "no", "No" or "NO"; finally, if it gets a different argument the function must use return to return the message "Lo siento, no te entendi"


@eggbert21: I believe I understood what you tried to say. Your code looks alright for me, couldn't find any possible syntatic error so maybe it could be the indentation or the texts being printed.

Sometimes the program that executes the codes get into some sort off bug and tells the user his/her code is not correct when in fact is it.
Like I said before, check the indentation and the messages and also make sure to use:

print apagado("Any string in here")

To actually print the message.

Quote me if there's anything else I can help you with!

Best regards,

Edit: in some cases, refreshing the browser and executing again works.


ok, it seems that i made some progress, hehe
with that line of code that you provided it seems that the code is working except for the "no" variants, take a look


even though it clearly shows that the message is displaying, it stills shows the error....what? hahahahahaha this is frustrating man...

Edit: i also tried refreshing, nothing happend


Here's a print screen of your code being executed.
I tested it, in this case, with "No" and such message didn't show up.
"Is it wrong to print the return value of a function?"
No, it's somehow quite common. We can even use it to compare things in if/elif statements (not in the else statement because you don't use parentheses nor compare anything to get inside of it).
Try refreshing your browser and executing, maybe that could work and let you pass.


ok, so this is sad right here:
i refreshed the browser, nothing happened
i deleted the cookies and cache to see if that could help, nothing happened
i refreshed again to see, nothing happened

Im starting to think this issue is related to the IDE or something like that hahaha, is just that is really frustrating because you start to think that you are the one with the problem, get´s on my nerves to be honest.

Anyways. Thank you very much for your help and for verifing my code :smiley: , without that i still would have doubts about my code heheheh, i guess i´ll just skip to the next lesson.


No problem at all :slightly_smiling:

Quote me if there's anything else I can help you with!

Best regards,


Alright then heheheh