2016-11-14 100 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 + "!")