《Python编程快速上手》10.8 实践项目
这个比较简单..看一下就知道错哪了
1 import random2 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.\')
以上是 《Python编程快速上手》10.8 实践项目 的全部内容, 来源链接: utcz.com/z/387686.html