猜拳游戏
"""
author:魏振东
data:2019.09.26
func:猜拳游戏
"""
import random
p_score = 0
c_score = 0
while True:
computer = random.randint(1,3)
player = int(input("1:石头,2:剪刀,3:布,4:退出\n"))
if player == 1 and computer == 3 or player == 2 and computer == 1 or player == 3 and computer == 2:
print('你赢了')
p_score+=1
elif computer == player:
print('平局')
elif player == 4:
print('游戏退出!\n你的得分为:'+str(p_score)+'分\n电脑得分:'+str(c_score)+'分')
break
elif player == 1 or player == 2 or player == 3:
print('电脑赢了')
c_score += 1
else:
print('不要搞事情,请重新输入!')
continue