【发布时间】:2014-10-18 10:34:25
【问题描述】:
我正在做一些计算机科学作业,并且正在尝试学习一些基本的 Python。我正在尝试执行 IF 语句,但我不断收到语法错误(顺便说一下,python 版本 3.3.3)。有人可以告诉我我做错了什么吗?请注意,虽然我的错误很可能出现在 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()
【问题讨论】:
-
发布您收到的实际错误消息
-
我得到的只是“语法错误”。它不会告诉我什么。
-
你是如何运行它的?你至少应该得到一个回溯。
标签: python if-statement syntax