Python学习-if分支-石头剪刀布游戏

#coding:utf-8

from random import randint

player=int(raw_input('请出拳 1.石头 2.剪刀 3.布 :'))

computer=randint(1,3)

if ((player == 1 and computer == 2)
        or (player == 2 and computer == 3)
        or (player == 3 and computer == 1)):
    print '电脑输了'
elif player==computer:
    print '打了平手'
else:
    print '你输了'

猜你喜欢

转载自blog.csdn.net/weixin_38892128/article/details/85564854