- 帖子
- 3
- 精华
- 0
- 积分
- 50
- 阅读权限
- 20
- 注册时间
- 2018-2-21
- 最后登录
- 2018-6-10
|
在接近最后的kick()显示invalid syntax是怎么回事呢,用的python 3
from random import choice
score=[0,0]
direction=['left','center','right']
def kick():
print('==== You Kick! ====')
print('Choose one side to shoot:')
print('left, center, right')
you =input()
print('You kicked ' + you)
com =choice(direction)
print('Computer saved ' + com)
if you != com:
print('Goal!')
score[0] += 1
else:
print('Oops...')
print ('Score: %d(you) - %d(com)\n' % (score[0], score[1]))
print('==== You Save! ====')
print('Choose one side to save:')
print('left, center, right')
you =input()
print('You saved ' + you)
com =choice(direction)
print('Computer kicked ' + com)
if you == com:
print('Saved!')
else:
print('Oops...')
score[1] += 1
print('Score: %d(you) - %d(com)\n'% (score[0], score[1])) #列表的數字用中括號
for i in range(5):
print('==== Round %d ====' % (i+1))
kick()
while(score[0]==score[1]): #平局再來
i+=1 #局數+1
print('=== Round %d ==='%(i+1) #顯示當前局數
kick()
if score[0]>score[1]:
print('You win!')
else:
print('You Lost.') |
|