2017-02-21 133 views
-2

您好我已經做了一段代碼,從我可以看到看起來都很好,但是當我試圖運行它時,它出現了一個語法錯誤,罰款(如圖)。我對Python非常陌生,我只學習了基礎知識,希望有人能找到解決方案。爲什麼我在python 3.6中得到隨機語法錯誤

name = input('what is your name') 
print ('hello' + name) 
print (',it is late december of 2025 and the nuke has been drooped over sheffield. you are our only hope') #this explanes the background story and askes the players name 
print ('please help us. we need you,' + name) 
job = input('please choose a class. medic, gunsman or scientist') 

if job == medic 
bandages = 5 
drugs = 5 
clean_siringes = 5 
dirty siringes = 0 #this sets the players items to the right amount 

health = 100 
food = 100 
water = 100   #this sets the players food, water, health and the citys peoples happiness 
peoples_happiness = 100 

print ('bandages' + bandages) 
print ('drugs' + drugs) 
print ('clean_siringes' + clean_siringes) 
print ('dirty siringes' + dirty_siringes) 
print ('health' + health 
print ('food' + food) 
print ('water' + water) 
print ('peoples_happiness' + peoples_happiness) 

這裏有語法錯誤的圖片:

enter image description here

+0

你錯過了':'。 –

+0

a':'後面的單詞'medic'比較需要用冒號結尾 – WhatsThePoint

回答

1

你缺少冒號在if聲明

if job == medic: 

結束,再加上你需要縮進的行那些在if子句中。

+1

只需留下評論並將其作爲簡單的印刷錯誤關閉即可...... –

+0

我猜他也意味着'if job =='醫生「'。 –

相關問題