|  | 
 
| 
我写的代码如下:
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册  
 复制代码print('---Guess a Number (in-between 1 to 100)---')
print('5 attempts allowed.')
guess = input('Please type a number: ')
temp = int(guess)
n=4
if temp==66:
      print('Correct!\nBut no reward.')
while temp!=66 and n>0:
      print(n, 'attempts left.')
      n=n-1
      if temp>66 and n>=0:
            guess = input('Go down a little bit: ')
            temp = int(guess)
      if temp<66 and n>=0:
            guess = input('Go up a little bit: ')
            temp = int(guess)
      if n==0 and temp!=66:
            print('No attempt left.')
      if temp==66:
            print('Correct!\nBut no reward.')
print('Game Over')
 运行时会出现以下红色部分这种情况,求指正
 ---Guess a Number (in-between 1 to 100)---
 5 attempts allowed.
 Please type a number: 50
 4 attempts left.
 Go up a little bit: 75
 3 attempts left.
 Go down a little bit: 65
 Go up a little bit: 70
 2 attempts left.
 Go down a little bit:
 
if temp>66 and n>=0:guess = input('Go down a little bit: ')
 temp = int(guess)
 elif temp<66 and n>=0:
 guess = input('Go up a little bit: ')
 temp = int(guess)
 | 
 |