Python-简单的石头剪刀布

import random
player = int(input("请输入0石头,1剪刀,2布:"))
computer = random.randint(0,2)
while True:
    if player<3 and player>=0:
        if(player==0 and computer==1) or (player==1 and computer==2) or (player==2 and computer==0):
            print("你赢了,电脑出的是:",computer)
            break
        elif player == computer:
            print("平局")
            break
        else:
            print("电脑赢,电脑出的是:",computer)
            break
    else:
        player=int(input("输入不合法,请重新输入:"))
        continue
print("游戏结束")

你可能感兴趣的:(Python,python,游戏)