Functions and if - else in python. Mutliple conditions. Codeacademy

后端 未结 9 1408
-上瘾入骨i
-上瘾入骨i 2021-02-06 12:19

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

9条回答
  •  不知归路
    2021-02-06 12:49

    I know this doesn't exactly fit the specification but this is another common option which would catch a few more permutations:

    def shut_down(s):
        s = s.upper()
        if s == "YES":
            return "Shutting down..."
        elif s == "NO":
            return "Shutdown aborted!"
        else:
            return "Sorry, I didn't understand you."
    

提交回复
热议问题