每当我尝试这个,它不起作用(输入= 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")
不是你的问题相关,但你有很多在你的代码多余的空格:'DEF amount_of_Chests():'应该只是'def amount_of_chests():'(也是大写''C'是坏风格) –
这就是骆驼套 –
其实'thisIsCamelCasing','ThisIsStudlyCasing'和'this_is_snake_casing'。我不确定'amount_of_Chests'会是什么;) - 无论如何,你会发现*大部分* Python代码都符合[pep8](https://www.python.org/dev/peps/ pep-0008 /)风格指南。如果您选择偏离标准,[它应该是一个很好的理由](https://www.youtube.com/watch?v=wf-BqAjZb8M)。 –