代码如下:
def your(kick):
direction=["1","2","3"]
from random import choice
com=choice(direction)
print("you chosed %s"%kick)
print("com chosed %s"%com)
if kick==com:
return True
else:
return False
score_you=0
score_com=0
score1=False
for score in range(5):
print("Round%d,you kick!"%(score+1))
print("choose one direction to kick!")
print("1,2,3")
kick=input()
score1==your(kick)
if score1==False:
print("you socred!")
score_you=score_you+1
else:
print("com saved!")
score_com=score_com+1
print("Round%d,you save!"%(score+1))
print("choose one direction to save!")
print("1,2,3")
kick=input()
score1=your(kick)
if score1==True:
print("you saved!")
score_you=score_you+1
else:
print("com socred!")
score_com=score_com+1
print("your socre:%d"%score_you)
print("com's socre:%d"%score_com)
if score_you>score_com:
print("you win!")
else:
print("you lose!")