Python剪刀石头布简单

img


python程序设计的剪刀石头布,编写程序与电脑进行游戏,有赢,平局,输三种情况。


from random import choice
games=['剪刀','石头','布']
flag = True

while flag:
    userInput = input('请输入剪刀、石头 或者 布: ')
    value = choice(games)
    if userInput == value:
        print('平局,再来!')
        continue
    else:
        if userInput == '剪刀' and value == '石头':
            print('你输了,哈哈哈哈!')
            continue
        elif userInput == '石头' and value == '布':
            print('你输了,哈哈哈哈!')
            continue
        elif userInput == '布' and value == '剪刀':
            print('你输了,哈哈哈哈!')
            continue
        else:
            print('你赢了,恭喜!')
            flag = 0