Review Function: Result of Raw Input in a function



I have a question, here i want to use de result of the raw_input to respond de function argument.

How can i do this?

respuesta = raw_input("Desea apagar la PC?")
s = respuesta.lower()

def apagado(s):
    if r=="si":
        return "Apagando..."
    elif r=="no" :
        return "¡Apagado cancelado!"
        return "Lo siento, no te entendí."

PD: srry for my inglish, i speak spanish hahahah !


Hi there!
I'm not sure I understand the question.
Do you want to call the function using the users input?
If so you can just do:


and that should use the input as a parameter.
Let me know if this didn't answer your question. :slight_smile:


Yes, the idea is use de input as a parametrer to response, and print "Apagando..." etc.
And I cant.

It´s ok what i do?

def apagado(input):
    if r=="si":
        return "Apagando..."
    elif r=="no":
        return "¡Apagado cancelado!"
        return "Lo siento, no te entendí."

raw_input("Desea apagar la PC?")

print apagado


Hey there,

Your code is on the right track, but it isn't working the way you intended it to.
Below is the correct code. Notice how I stored the raw_input under a variable. That way I can make changes to it as necessary. Also, when I called the function, I called it using the built in python keyword: raw_input, as a parameter.
This should do what you wanted it to do. Let me know if it doesn't. Otherwise, have a great day!

def apagado(x):
r = raw_input("Desea apagar la PC?")
r = r.lower()
if r=="si":
print "Apagando..."
elif r=="no":
print "Apagado cancelado!"
print "Lo siento, no te entendi."


Also for some strange reason. Using characters like í and ¡ prevent the code from working. Not sure why, but besides that, the code should work flawlessly :slight_smile:



Now i understand the logic behind, thats was what i need.



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