- 帖子
- 21
- 精华
- 0
- 积分
- 96
- 阅读权限
- 20
- 注册时间
- 2016-12-2
- 最后登录
- 2017-2-13
|
def guocheng1():
print '==== Round %d - You %s! ====' %( i+1 , 'kick' )
print 'Choose one side to %s:' %'shoot'
print 'left, center, right'
you = raw_input()
print 'You %s '% 'kicked' + you
com = choice(direction)
print 'Computer %s '% 'saved' + com
if you == com:
print 'Saved!'
else:
print 'Oops...'
score_com += 1
print 'Score: %d(you) - %d(com)\n' % (score_you, score_com)
def guocheng2():
print '==== Round %d - You %s! ====' %( i+1 , 'save' )
print 'Choose one side to %s:' %'save'
print 'left, center, right'
you = raw_input()
print 'You %s '% 'save' + you
com = choice(direction)
print 'Computer %s '% 'kicked' + com
if you == com:
print 'Saved!'
else:
print 'Oops...'
score_com += 1
print 'Score: %d(you) - %d(com)\n' % (score_you, score_com)
from random import choice
score_you = 0
score_com = 0
direction = ['left', 'center', 'right']
for i in range(5):
guocheng1()
guocheng2()
我想把两个def guocheng合在一块,最后导出的时候再用%修改,一直没成功,不知道这样可不可行
而且像这样分开写print '==== Round %d - You Kick! ====' % (i+1)这里运行的时候第二次还是round 1
老师你的也是这样
|
|