0
def playAgain():
b = input('Do you want to play again? y/n')
if b == ('y'):
def startGame():
startGame()
else:
print('Goodbye!')
time.sleep(1)
sys.exit()
import random
import time
import sys
global shots
shots = 0
while shots <=5:
chanceofDeath =random.randint(1,6)
input('press enter to play Russian roulette.')
if chanceofDeath ==1:
shots = shots + 1
print (shots)
print('You died.')
time.sleep(1)
playAgain()
else:
shots = shots + 1
print (shots)
print ('click')
if shots == 5:
print('You won without dying!')
time.sleep(1)
playAgain()
當我運行該程序時,當它要求再次播放或不播放時,如果您選擇yes,它將起作用,但會從最後一次拍攝開始。例如,如果您在第二次拍攝時死亡並再次播放,而不是重新開始,那麼它將立即從3開始。我如何使照片每次都重置?如何使每次都重置全局值?