我的二十一点游戏有效,但我怎么能循环它,以便在游戏结束时,他们可以选择再次玩?非常感谢你们!只需要循环。干杯
import random
endGame = (False)
dealer = random.randrange(2,20)
player = random.randrange(2,20)
print ("\n*********LETS PLAY BLACK JACK***********\n")
print ("Your starting total is "+str(player))
while endGame==(False):
action =input("What do you want to do? stick[s] or twist[t]? ")
if action == ("s"):
print ("Your total is "+str(player))
print ("Dealer's total is "+str(dealer))
if player > dealer:
print ("*You win!*")
else:
print ("Dealer wins")
endGame = True
if action == ("t"):
newCard = random.randrange(1,10)
print ("You drew "+str(newCard))
player = player + newCard
if player > 21:
print ("*Bust! You lose*")
endGame = True
else:
print ("Your total is now "+str(player))
if dealer < 17:
newDealer = random.randrange(1,10)
dealer = dealer + newDealer
if dealer > 21:
print ("*Dealer has bust! You win!")
endGame = True