#猜拳游戏:电脑随机产生石头剪刀布,键盘输入你要出的拳,(布: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 you0 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 you0 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
加粗样式