2
我正在編寫一個程序來計算兩個用戶的分數。當他們中的任何一個得分爲10並且相應的玩家獲勝時遊戲結束。python雖然循環不終止
我寫的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))
謝謝,這有幫助。:) – RamyaV