📌  相关文章
📜  如何在 python 中的输入中添加限制 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:28.591000             🧑  作者: Mango

代码示例2
while True:    
    try:
        hp_cur=int(input("Enter the current number of HP (1-75): "))
    except ValueError: # used to check whether the input is an int
        print("please insert a int type number!")
    else: # is accessed if the input is a int
        if hp_cur < 1 or hp_cur > 75:
            print("please insert a number in the given limit")
        else: # if number is in limit, break the loop
            break