我正在做一些計算機科學作業,並試圖學習一些基本的python。我試圖做一個IF語句,但我不斷收到語法錯誤(順便說一下,Python 3.3.3版本)。有人可以告訴我我做錯了什麼嗎?請注意,雖然我的錯誤很可能在IF聲明中,但它也可能在其他地方。謝謝。我在Python中錯誤地構造了我的IF語句嗎?
print ("Hello. What is your name?")
print("")
name = input()
print("")
print("Hello ", name, ". What lesson do you have next?")
print("")
lesson = input()
print("")
print("I hate ", lesson, ". You're rubbish.")
wait = input()
print("...")
wait = input()
print("...")
wait = input()
print("...")
wait = input()
print("")
print("Do you like me? If you love me, type 1. If you hate me, type 2. If you're inbetween, type 3.")
print("")
emotion = input()
print("")
if emotion == 1:
print ("Awwwwwww.")
print ("")
else:
if emotion == 2:
print ("Yeah well I don't like you either.")
print ("")
else:
if emotion == 3:
print ("Yeah OK fair enough")
print ("")
else:
print("I said type 1, 2 or 3. I'm going now.")
print("")
print("I'm going now. Goodbye friend.")
print("")
wait = input()
quit()
使用'如果/ elif's' – 2014-10-18 10:36:02
後實際的錯誤消息你 – thefourtheye 2014-10-18 10:36:28
我得到的是「語法錯誤」。它不會告訴我什麼。 – 2014-10-18 10:36:55