- 帖子
- 8
- 精华
- 0
- 积分
- 31
- 阅读权限
- 10
- 注册时间
- 2017-8-30
- 最后登录
- 2017-9-8
|
本帖最后由 wujinyekong 于 2017-9-5 17:12 编辑
from random import choice
score_you = 0
score_com = 0
direction = ['left', 'center', 'right']
for i in range(5):
print '==== Round %d - You Kick! ====' % (i+1)
print 'Choose one side to shoot:'
print 'left, center, right'
you = raw_input()
print 'You kicked ' + you
com = choice(direction)
print 'Computer saved ' + com
if you != com:
print 'Goal!'
score_you += 1
else:
print 'Oops...'
print 'Score: %d(you) - %d(com)\n' % (score_you, score_com)
print '==== Round %d - You Save! ====' % (i+1)
print 'Choose one side to save:'
print 'left, center, right'
you = raw_input()
print 'You saved ' + you
com = choice(direction)
print 'Computer kicked ' + com
if you == com:
print 'Saved!'
else:
print 'Oops...'
score_com += 1
print 'Score: %d(you) - %d(com)\n' % (score_you, score_com)
按照这个代码,可以随便写一个['left', 'center', 'right']之外的字符,都判定电脑没守中。
我想知道
if you != com:
print 'Goal!'
score_you += 1
这个判断句说的啥?求指导
|
|