《Python编程快速上手》10.8 实践项目

这个比较简单..看一下就知道错哪了

 1 import random
 2 guess = ''
 3 while guess not in ('heads', 'tails'):
 4     print('Guess the coin toss! Enter heads or tails:')
 5     guess = input()
 6 toss = random.randint(0,1)
 7 if toss == 0:
 8     toss = 'tails'
 9 else:
10     toss = 'heads'  # 0 is tails, 1 is heads
11 if toss == guess:
12     print('You got it!')
13 else:
14     print('Nope! Guess again!')
15     guess = input()
16     if toss == guess:
17         print('You got it!')
18     else:
19         print('Nope. You are really bad at this game.')

 

posted @ 2018-08-08 21:55  eugene_21  阅读(216)  评论(0编辑  收藏  举报