为什么变量输出“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 answer is ' + answer)

回答

guess = print('Sorry wrong answer. Try again.n')

的返回值printNone

看一下input从用户那里获取值的函数。


以上是为什么变量输出“None”的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>