python猜拳小游戏

import random
for _ in range(10):#进行比赛的次数
my_list =['剪刀','石头','布']
player = input("请输入序号1剪刀、2石头、3布")
if player:
player =int(player)
s =[i for i in range(1,4)]
if player not in s:
print("请输入正确的号码")
continue
index = random.randint(1, 3)
#给电脑绑定序号
cumputer =my_list[index -1]
print(cumputer)
#思路:先考虑你赢得各种情况
if player==1 and index ==3 or player == 2 and index ==1 or player==3 and index==2 :
print("好厉害你赢了,电脑出了%s" % cumputer)
elif player ==index:
print("平局电脑出了%s" % cumputer)
else:
print("你输了电脑出了%s" % cumputer)

posted @ 2019-11-26 20:35  未来全栈攻城狮  阅读(1753)  评论(0编辑  收藏  举报