2016-11-14 64 views
-2
name = raw_input("Hello sir! What is your name?") 
print ("Nice to meet you " + name + "! Where were you born?") 
born = input(" ") 
print ("So your name is " + name + " and you were born in " + born + "!") 

And im getting the error " Nice to meet you Will! Where were you born? Florida Traceback (most recent call last): File "C:/Users/39.cr/PycharmProjects/untitled/test.py", line 3, in born = input(" ") File "", line 1, in NameError: name 'Florida' is not defined "我不知道我怎么会做这项工作

+0

'input'应该在这两种情况下'raw_input'在Python 2。 –

回答

0

您需要使用的raw_input(“”),以获得出生地的名称,以及因为你使用Python 2.在Python 3的代码会工作。原因是在Python 2中,您需要使用raw_input()以获取字符串而不是其他对象类型。

0

试试这个:

name = raw_input("Hello sir! What is your name?") 
born = raw_input("Nice to meet you " + name + "! Where were you born?") 
print("So your name is " + name + " and you were born in " + born + "!")