我试图在python 3.4版本中运行此函数

时间:2016-03-26 20:41:12

标签: python python-3.4

我试图在python 3.4版本中运行此函数。

tries = 0
answer = "Watson"
while(tries <= 3):
   print("What is the name of the computer that played on Jeopardy?")
   response = raw_input()
   tries = tries + 1
   if (response == "Watson"):
      print("That is right!")
      break;
   elif (tries == 3):
      print("Sorry. The answer is Watson.")
      break;
   else:
      print("Sorry. Try again.")

我收到错误:

NameError: name 'raw_input' is not defined

我是否需要为python版本3.4做一些不同的事情

1 个答案:

答案 0 :(得分:1)

在Python 3中,input()不是raw_input()

  

raw_input()已重命名为input()

What is new in Python 3.