我正在编写一个程序来计算两个用户的分数。当他们中的任何一个得分为 10 并且各自的玩家获胜时,游戏结束。
我将while循环写为:
while (score1 != 10) or (score2 != 10):
...
我的程序不会终止。
这是代码:
player1 = input("Enter name for Player1")
player2 = input("Enter name for Player2")
score1=0
score2=0
print ("Score for Player1 is: %d,Score for player2 is :%d" %(score1,score2))
while (score1 != 10) or (score2 != 10):
player =input("enter name for player")
if player is player1:
score1=score1+1
if player is player2:
score2=score2+1
print ("Score for Player1 is: %d,Score for player2 is :%d" %(score1,score2))