用户输入验证问题

时间:2016-01-14 16:42:16

标签: python integer

每当我尝试这个时它都不起作用(输入= 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")

1 个答案:

答案 0 :(得分:4)

执行return语句后没有代码,因此永远不会调用amount_of_Bandits()