多个Elif的Elif错误?

2024-09-27 17:44:03 发布

您现在位置:Python中文网/ 问答频道 /正文

当我编写文本游戏时,我放了两个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

Tags: andofthetoforifexitbe

热门问题