Instead of checking for different capitalization combinations, you can use the lower function to return a copy of s in lower case and compare with that.
def shut_down(s): if s.lower() == "yes": return "Shutting down..." elif s.lower() == "no": return "Shutdown aborted!" else: return "Sorry, I didn't understand you."
It is much simpler and easier to debug. Alternatively, you can also use upper and compare with "YES" and "NO" .
If this does not help due to the coincidence of cases like nO , I would go with the in statement:
def shut_down(s): if s in ("yes","Yes","YES"): return "Shutting down..." elif s in ("no","No","NO"): return "Shutdown aborted!" else: return "Sorry, I didn't understand you."
source share