简体   繁体   English

为什么这个elif语句会抛出错误?

[英]Why is this elif statement throwing an error?

class TheBridge(Scene):

def enter(self):
    print "You burst into the bridge with the bomb"
    print "There are a number of gothons standing about"
    print "and looking scared of the bomb you currently have underneath your arm"
    print "They look nervous about what you are going to do"

    action = raw_input("> ")


    if action == "Throw the bomb":
        print "You throw the bomb at the gorcons on the bridge"
        print "They pure and utter crap themselves and pull out their laser blasters and shhot you dead"
        print "at least the bomb will kill the gorcons, you die a hero"
        return 'death'

    elif action == "Put the bomb down slowly":
        print "You pull you laser blaster from your holster and point it at the bomb"
        print " You very slowly set the bomb on the ground and move backwards"
        print "You then jump back through the door and start firing your gun at the"
        print "lock and you blast it so the gorcons can't escape"
        print "You then procede to try and find an escape pod"
        return 'escape_pod'

    else:    
        print "DOES NOT COMPUTE"
        return "the_bridge"

It's throwing a syntax error for some reason. 由于某种原因,它会抛出语法错误。 Maybe I'm a complete idiot and can't see something blindingly obvious. 也许我是一个完全白痴,看不到令人眼花缭乱的明显事物。 Definitely not the spacing or indentation or anything like that as I have checked that. 绝对不是间距或缩进或类似的东西,因为我已经检查过。

Any ideas? 有任何想法吗?

Error Message: 错误信息:

  File "ex43.py", line 131
    elif action == "Put the bomb down slowly":
       ^
SyntaxError: invalid syntax`

You are mixing tabs and spaces (your copied post here certainly does). 你正在混合制表符和空格(这里复制的帖子当然可以)。

Run your code with python -tt and fix any problems that finds. 使用python -tt运行代码并修复发现的任何问题。

Preferably, replace all tabs with spaces and configure your editor to do so automatically. 最好用空格替换所有选项卡,并将编辑器配置为自动执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM