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
def shut_down(s):
return ("Shutting down..." if s in("Yes","yes","YES")
else "Shutdown aborted!" if s in ("No","no","NO")
else "Sorry, I didn't understand you.")
GordonsBeard's idea is a good one. Probably "yEs" and "yES" etc are acceptable criteria;
Then I propose in this case:
def shut_down(s,d = {'yes':"Shutting down...",'no':"Shutdown aborted!"}):
return d.get(s.lower(),"Sorry, I didn't understand you.")