每当我有两个冲突大于我如何在那里设置限制时



嗨,我是编程新手。在此之前,我使用过Game Maker,所以我需要帮助。每当我有两个冲突大于我如何在那里设置限制时。例: if (weight>=20): (print(example)) if (weight>=30): (print(example)) 所以如果我输入 35,它会打印这两件事。那么我如何让它只打印一件事。谢谢你的时间。P.S我正在使用python 3.6。

答案在 elif 语句中

if x > a:
    # x is greater than a
    #do something
    pass
elif x > b:
    # x is not greater than a, but greater than b
    # do something
    pass
else:
    # do something else
    pass

相关内容

最新更新