剪刀石头布的小程序

from random import  *

def check(x,y):
    if ((x == 1 and y == 2)
            or (x == 2 and y == 3)
            or (x == 3 and y == 1)):
        print('You win!')
    else:
        print('You lose!')

running = True
while running:
    player = int(input('请输入您的出拳(石头:1,剪刀:2,布:3):'))
    computer = randint(1, 3)
    print('您的出拳: %d --电脑的出拳:%d' % (player, computer))

    if player == computer:
        print('您的出拳和电脑相同,请重新出拳!')
    else:
        running = False

check(player,computer)

你可能感兴趣的:(python学习)