Python写小游戏之石头剪刀布,while循环if判断语句

#剪刀石头布实验
game = input("""
#剪刀石头布小游戏#
本游戏为五局三胜制
请输入go开始挑战
""")
num=0
false=0
true=0
planish=0
while game=='go' and num<5:
    num+=1
    a=input('第'+str(num)+'回合,你要出什么呢?\n1、石头 2、剪刀 3、布\n请输入数字:')
    if int(a)==1:
        import random
        b=random.randrange(1, 4, 1)
        if b==3:
            print('''
输啦!人家出的布
            ''')
            false+=1
        elif b<2:
            print('''
真不好意思,平局呢!我也是石头
            ''')
            planish+=1
        else:
            print('''
哎呀!侥幸让你赢了,我是布
            ''')
            true+=1
    elif int(a)==2:
        import random
        b = random.randrange(1, 4, 1)
        if b==1:
            print('''
不小心赢了,哈哈!我是石头
            ''')
            false+=1
        elif b>2:
            print('''
真的是让你走狗屎运了!我是布
            ''')
            true+=1
        else:
            print('''
平局,你个小次佬我也是剪刀
            ''')
            planish+=1
    elif int(a)==3:
        import random
        b = random.randrange(1, 4, 1)
        if b==1:
            print('''
***,你再赢我就生气了!我是石头
            ''')
            true+=1
        elif b>2:
            print('''
平局平局,算你走远!我也是布
            ''')
            planish+=1
        else:
            print('''
hhh,你真垃圾呢!我是剪刀
            ''')
    else:
        print('''
给我好好玩!别瞎输入
        ''')
    while num==5:
        if true>false:
            print('你赢了'+str(true)+'局\n输了'+str(false)+'局\n有'+str(planish)+'局是平局\n最后还是你赢了呢。。。')
            break
        elif true 
 

你可能感兴趣的:(python练习小实验,python,开发语言)