from random import choice
def goal(i,score_you):
print('========round %d u kick=========' % i+1)
print('choose one side to shoot:')
print(list(direction))
you=input()
print('you kicked'+ you)
com=choice(direction)
print('computer saved '+ com)
if you != com:
print('goal!')
score_you += 1
else:
print('oops~')
def save(i,score_com):
print('========round %d u save======== '% i+1)
print('choose one side to save:')
print(list(direction))
you = input()
print('you saved'+ you)
com= choice(direction)
print('computer kicked '+ com)
if you != com:
print('goal')
score_com +=1
else:
print('oops~')
score_you = 0
score_com = 0
direction=('left','center','right')
for i in range(5):
if (i+2)/2 == 0:
goal(i,score_you)
print('''round %d
you:%d computer:%d'''% (i+1,score_you,score_com))
else:
save(i,score_com)
print('''round %d
you:%d computer:%d''' % (i + 1, score_you, score_com))
下面这是错误信息:
C:\Users\heavymetalmaniac\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/heavymetalmaniac/PycharmProjects/list_goal/goal.py
Traceback (most recent call last):
File "C:/Users/heavymetalmaniac/PycharmProjects/list_goal/goal.py", line 40, in
save(i,score_com)
File "C:/Users/heavymetalmaniac/PycharmProjects/list_goal/goal.py", line 16, in save
print('========round %d u save======== '% i+1)
TypeError: must be str, not int
应该怎么改啊
新手求助