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, the following error occurs:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'yes' is not defined*
Please help me...is there some kind of mistake in my code?
yesinstead of"yes"in the first line of your file, but you didn't show it so hard to say for sure... Advice: READ what the compiler says :)