猜拳 三局两胜

"""
猜拳 三局两胜
"""
i = 0
t = 0
while i < 3:
    i = i + 1
    r = random.randint(1, 3)
    g = int(input('1剪刀 2石头 3布'))
    if r == g:
        print('机器出{} 你出{} 平'.format(r, g))
    elif r == 1:
        if g == 2:
            print('机器出{} 你出{} 赢'.format(r, g))
            t = t + 1
        elif g == 3:
            print('机器出{} 你出{} 输'.format(r, g))
            t = t - 1
    elif r == 2:
        if g == 1:
            t = t - 1
            print('机器出{} 你出{} 输'.format(r, g))
        elif g == 3:
            print('机器出{} 你出{} 赢'.format(r, g))
            t = t + 1
    elif r == 3:
        if g == 1:
            print('机器出{} 你出{} 赢'.format(r, g))
            t = t + 1
        elif g == 2:
            print('机器出{} 你出{} 输'.format(r, g))
            t = t - 1
    else:
        pass
    if t == -2:
        print('您输了')
        break

if t == 0:
    print('平手')
elif t == 2 or t == 1:
    print('您赢了')
else:
    if t == -2:
        pass
    else:
        print('您输了')

你可能感兴趣的:(猜拳 三局两胜)