python分数等级循环实现_python循环计数分数

我做了一个石头,布剪刀游戏,工作很好,但我想为用户和人工智能增加一个分数,计算他们各自赢了多少次。我试着用一对分数变量,然后每次都加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()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值