我正在製作一個簡單的遊戲程序,但是在初始遊戲開始時遇到了麻煩。我有三個功能設置:開始,遊戲,結束。問題是,一旦程序創建了函數,它就會終止,因爲沒有重新開始再次通過函數。變量值導致過早退出程序
這裏的最後一個函數,gameEnd:
def gameEnd ():
print ('Would you like to play again? Y/N.')
playAgain = '' **part of the problem is here; the computer reads playAgain as **
input (playAgain) **''. Because playAgain is not equal to Y or y, the program **
if playAgain == 'Y' or 'y': **exits without ever starting. I need to move **
gameCore **playAgain somewhere logical.**
else:
print ('You won Caves of Doom, Caves of Delight ' + wins + ' times.')
print ('You lost Caves of Doom, Caves of Delight ' + losses + ' times.')
if wins > losses:
print ('Good for you. You have a winning record!')
elif wins == losses:
print ('Well, you did okay; neither good nor bad.')
elif wins < losses:
print ('Tough luck. You have a losing record.')
time.sleep (1)
print ('Farewell, ' + name + ',' + ' and may we meet again sometime soon.')
請妥善編輯代碼。爲什麼會有「**」? – ATOzTOA