python中if函数多个条件并列,函数和if-else in python。多条件。密码学

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".

If it gets anything other than those inputs, the function should return "Sorry, I didn't understand you."

The code I wrote so far is below. It makes errors, e.g. given "No" as the argument, it does not return "Shutdown aborted!" as expected.

def shut_down(s):

if s == "Yes" or "yes" or "YES":

return "Shutting down..."

elif s == "No" or "no" or "NO":

return "Shutdown aborted!"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值