我做了一个石头,布剪刀游戏,工作很好,但我想为用户和人工智能增加一个分数,计算他们各自赢了多少次。我试着用一对分数变量,然后每次都加1,但总是给0。我在第一个if语句中保留了增量,以显示我的意思。我也试过字符串.count但没用。任何帮助都将不胜感激。在import sys
from random import randint
import math
choice1=input("would you like to play a game of rock,paper and scissors: ")
while choice1=="yes":
choice2=input("please choose rock,paper or scissor: ")
computer=randint(1,3)
score=0
score2=0
if choice2 in ("rock","paper","scissor"):
if computer==1:
print("You have chosen "+ choice2 + " and the computer has chosen rock ")
if choice2=="rock":
print("It'/s a draw ")
elif choice2=="paper":
print("You win! ")
score + 1
elif choice2=="scissor":
print("You lose :( ")
score2 +
else:
sys.exit()
elif computer==2:
print("You have chosen " + choice2 + " and the computer has chosen paper ")
if choice2=="rock":
print("You lost :( ")
elif choice2=="paper":
print("It'/s a draw")
elif choice2=="scissor":
print("You won! ")
else:
sys.exit()
elif computer==3:
print("You have chosen " + choice2 + " and the computer has chosen scissor ")
if choice2=="rock":
print("You won! ")
elif choice2=="paper":
print("you lost :( ")
elif choice2=="scissor":
print("It'/s a draw ")
else:
sys.exit()
choice3=input("Would you like to play again? Type yes or no: ")
if choice3=="no":
print (score)
print (score2)
sys.exit()
else:
sys.exit()
else:
print("GoodBye")
sys.exit()