猜拳小游戏

import random

all_list = ['石头','剪刀','布']

win_list = [['剪刀'+'布'], ['石头'+'剪刀'], ['布'+'石头'] ]

pouter ='''(0) 石头(1) 剪刀(2) 布

请选择0/1/2: '''

pwin =0

cwin =0

draw =0

while pwin <2 and cwin <2:

        computer = random.choice(all_list)

        ind =int(input(pouter))

        player = all_list[ind]

        print('你的出拳是:%s, 计算机出拳是:%s' % (player, computer))

        if player == computer:

                print('平局')

                draw +=1

        elif [player, computer]in win_list:

                pwin +=1    

                print("YOU WIN!")

        else:

                cwin +=1

                print("YOU LOSE!")

        g = pwin + cwin + draw

if pwin ==2:

print('经过%s回合后你赢了,赢%s局,输%s局,平局%s局' % (g, pwin, cwin, draw))

else:

print('经过%s回合后你输了,赢%s局,输%s局,平局%s局' % (g, pwin, cwin, draw))

你可能感兴趣的:(猜拳小游戏)