有多个elif的Elif错误?

时间:2016-06-20 21:50:43

标签: python syntax

我在编写文本游戏时添加了两个elif语句,但是当我有第二个elif时,我收到语法错误。使用一个elif,它可以正常工作,但有两个它不起作用。

exit = raw_input("Do you exit the office?")
if exit == "yes":
    print("Shocked, frozen solid, Stanley found himself unable to move for the longest time. But as he came to his wits and regained his senses, he got up from his desk and stepped out of his office.")
elif exit == "no":
    print("But Stanley just couldn't handle the pressure. What if he had to make a decision? What if a crucial outcome fell under his responsibility? He had never been trained for that! No, this couldn't go any way except badly. The right thing to do now, Stanley thought to himself, is to wait. Nothing will hurt me. Nothing will break me. In here, I can be happy, forever. I will be happy. Stanley waited. Hours passed. Then days. Had years gone by? He no longer had the ability to tell. But the one thing he knew for sure, beyond any doubt, was that if he waited long enough, the answers would come. Eventually, some day, they would arrive. Soon, very soon now, this will end. He will be spoken to. He will be told what to do. Now it's just a little bit closer. Now it's even closer. Here it comes.")
elif exit == "window"
    print("At first, Stanley assumed he had broken the map, until he heard this narration and realized it was part of the game all along. He then praised the game for its insightful and witty commentary into the nature of video game structure and its examination of structural narrative tropes.")
Traceback (most recent call last):
  File "python", line 9
    else exit == "window"
            ^
SyntaxError: invalid syntax

2 个答案:

答案 0 :(得分:3)

我认为在" window"

之后你需要一个冒号

答案 1 :(得分:0)

“窗口”后需要冒号

elif exit == "window":