用户输入验证问题

2024-09-19 23:33:14 发布

您现在位置:Python中文网/ 问答频道 /正文

每当我尝试这个,它不工作(输入=6)。它把我送到上一个菜单,说输入无效。你知道吗

Code in Python that does not work.

def amount_of_Chests () :
    chestCount = 0
    amount_of_Chests_Display ()
    while chestCount <4 :
        chestCount_string = input("Please Make Sure You Enter Enough Chests\nPlease Enter How Many Chests You Would Like (Min.4)")
        chestCount = int(chestCount_string)
        if chestCount < 4 :
            print ("\nThere Are Not Enough Chests, Please Try Again.")
            amount_of_Chests_Display ()
        if chestCount > 3 :
            return chestCount
            amount_of_Bandits ()
        else :
            print ("Sorry that input is not valid. Please try Again.\n")

Tags: ofyouinputstringifthatdisplaynot