我有一个针对儿童的 Python 编程拼写游戏,如果玩家在完成游戏后单击“是”,我需要让它循环/重新启动,如果他们单击“否”则退出程序。
这是我编程的顶峰。
#Declare Constants and Variables
Score = 0
PlayerAnswer = 0
playOn = 0
while playOn != "Yes":
这就是结尾,我希望玩家能够在easygui按钮框上单击“是”时重复游戏。
playOn = easygui.buttonbox ("Do you want to play again?", choices = ["Yes", "No"])
if playOn == "Yes":
Score = 0 #resets score count, if player wants to play again
elif playOn == "No":
easygui.msgbox ("Bye for now. Hope you'll play the game again soon!")