def Commands():
command = raw_input("Type 'Mod', 'Run', 'Exit', or 'Help':")
elif command == "Run" :
restart = True
break
if groups == 4 :
restart = True
while restart :
restart = False
Commands()
如何讓此函數正常工作? 「restart = True」「break」行不會再次啓動前一個「while」循環。我在多個「if」語句中使用這些命令,並希望避免爲每個代碼重複使用80多行代碼。我刪除了無關的代碼,正常工作。作爲函數嵌套'While'循環
如果沒有'if',你就不能有'elif'。從你的'commands()'函數返回'True'或'False',並用它來確定你是否應該重新啓動。 – khelwood
我有,如果ELIF和其他,我刪除他們,因爲他們工作正常,並希望保持短代碼,並專注於重啓的問題,並打破不啓動外'while'循環 – Miller