小编NOT*_*GIF的帖子

为什么变量输出“None”

我试图帮助我的朋友做一个猜谜项目,但由于某种原因,guess 变量是 NoneType。你能帮我和我的朋友吗?

注意:出于技术原因,我已将 input() 替换为“hi”。

answer = "whatthing" #Change this to the answer
still_guessing = True
attempts = 1

guess = 'hi'
while still_guessing and attempts < 3:
  print(f'{guess}')
  if guess == answer.lower():
   print('Correct answer!')
   final_score = (3 - attempts)
   still_guessing = False
  else:
    guess = print('Sorry wrong answer. Try again.\n')
    print(f'Tries: {attempts}\n')
    print(f'You have {3 - attempts} left.\n')
    attempts += 1

  if attempts == 3:
    print('You coudn\'t find the answer in three tries, u suck!\n')
    print ('The correct …
Run Code Online (Sandbox Code Playgroud)

python variables python-3.x

0
推荐指数
1
解决办法
41
查看次数

标签 统计

python ×1

python-3.x ×1

variables ×1