Sunday, 25 August 2013

Custom python function not working

Custom python function not working

I was learning Python from Codecademy.
There's a question:
Write a function, shut_down, that takes one parameter (you can use
anything you like; in this case, we'd use s for string). The shut_down
function should return Shutting down... when it gets Yes, yes, or YES as
an argument, and Shutdown aborted! when it gets No, no, or NO.
In response to this i wrote this:
def shut_down(n):
p=n.lower()
if p=="yes":
return "Shutting down..."
elif p=="no":
return "Shutdown aborted!"
But when i try to run it following error occurs:
Traceback (most recent call last): File "", line 1, in NameError: name
'yes' is not defined
Please help me... is there some kind of mistake in code.

No comments:

Post a Comment