闲来无事写个python猜拳游戏

#猜拳游戏:电脑随机产生石头剪刀布,键盘输入你要出的拳,(布:0 剪刀 1 石头 2),判断哪方赢
import random
count=1
game = {“0”:“布”,“1”:“剪刀”,“2”:“石头”}
while count<=3:
comp=random.randrange(3)
you=int(input(“0:布\n1:剪刀\n2:石头\n你出拳:\n”))
if youcomp:
print(“电脑本次出的是%s”%(game.get(str(comp))))
print(“本次平局”.center(20,"*"))
else:
if you
0 and comp1 or you1 and comp2 or you == 2 and comp0:
print(“电脑本次出的是%s” % (game.get(str(comp))))
print(“第%d轮电脑方获胜”%(count))
if count 3:
print(“最终电脑方获胜”)
break
elif you
0 and comp1 or you1 and comp0 or you == 2 and comp1:
print(“电脑本次出的是%s” % (game.get(str(comp))))
print(“第%d轮玩家方获胜” % (count))
if count ==3:
print(“最终玩家方获胜”)
break
else:
print(“输入错误!重新猜”)
continue
count+=1
加粗样式

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值