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 func
Welcome to SO. I am going to walk through the answer, step-by-step.
s = raw_input ("Would you like to shut down?")
This asks if the user would like to shut down.
def shut_down(s):
if s.lower() == "yes":
print "Shutting down..."
elif s.lower() == "no":
print "Shutdown aborted!"
else:
print "Sorry, I didn't understand you."
This is probably new to you. If you have a string, and then .lower()
it changes all input from s
to lowercase. This is simpler than giving a list of all possibilities.
shut_down(s)
This calls the function.