2016-04-09 73 views
0
#dating sim 
energy = 10 
flirtpower = 5 
print ('welcome to Paragonia dating simulator!') 
print ('it is a sunny day at the end of the summer. You are new to 
Paragonia Highschool.') 
print ('A cute blonde boy walks up to you. he says:') 
name = int (input ("what's your name?")) 
print ('-Nice too meet you, ' name ,'! My name is Alex, Alex Snowdon. 
He smiles at you.') 

python說'無效語法',並突出顯示變量'name'。我究竟做錯了什麼?我是一個完整的初學者...python不接受我的變量

+0

你forg在之前的字符串和'name'之間加一個逗號。 –

回答

1

你之前,你的變量name

print ('-Nice too meet you, ', name ,'! My name is Alex, Alex Snowdon. He smiles at you.') 

也是正確的忘記一個逗號,你要面對另外一個錯誤,因爲你投了輸入到int,我認爲你想作爲一個str

更改此:name = int (input ("what's your name?"))

要:

name = input ("what's your name?") 

寫這篇避免的問題,如這是你的字符串中使用format,並把{},你要放置變量更簡單的方法:

print ('-Nice too meet you, {}! My name is Alex, Alex Snowdon. He smiles at you.'.format(name)) 
0
print ('-Nice too meet you, ', name ,'! My name is Alex, Alex Snowdon. He smiles at you.') 
#You forgot a comma here  ^, and you cannot put a string over multiple lines, 
unles you use triple-commas, like this: 

"""This is a string 
that goes over multiple lines.""" 
+0

ahhh我忘了!謝謝:) –

0

在這一行

print ('-Nice too meet you, ' name ,'! My name is Alex, Alex Snowdon. 
He smiles at you.') 

你忘了把一個跟從「 - 尼斯太滿足你,」 [插入昏迷這裏]名,...