Python 3.x python 3中的预期缩进错误

Python 3.x python 3中的预期缩进错误,python-3.x,Python 3.x,我有一个我刚刚开始的项目,我试着编译它,在第8行,无论我做什么,它总是有一个错误,说它需要一个缩进块,我找不到任何错误。我读过其他的问题,它们根本没有帮助。它是编译器中的一个bug,还是因为某种原因而不起作用 def main(): print("This game is the first created by the G.R.R. Digital Entertainment Division.") a = input("Welcome to The Forest. It is

我有一个我刚刚开始的项目,我试着编译它,在第8行,无论我做什么,它总是有一个错误,说它需要一个缩进块,我找不到任何错误。我读过其他的问题,它们根本没有帮助。它是编译器中的一个bug,还是因为某种原因而不起作用

def main():
    print("This game is the first created by the G.R.R. Digital Entertainment Division.")
    a = input("Welcome to The Forest. It is currently dawn in the middle of a temperate forest. You wake up, unknown of your surroundings. What do you do? ")
    if a == 'Go north' or 'Go North':
        print("You went North until you came to the border of the forest and a pasture. You see house with smoke coming out of the chimney ahead of you, a creek to your right, a meteor coming in from your left, and a forest behind you.")
    elif a == 'Go West' or 'Go west':
    elif a == 'Go east' or 'Go East':
    elif a == 'Go south' or 'Go South':
    elif a == 'Check supplies' or 'Check Supplies':
        print("You currently have a Compass, a dagger, a cyanide pill for suicide, a bottle of iodine, clothes, and a fannypack.")
    a =
    elif a == 'suicide' or 'Suicide':
    else:
错误如下:

  Traceback (most recent call last):
    File "python", line 7
      elif a == 'Go east' or 'Go East':
         ^
  IndentationError: expected an indented block

使用
pass
来“忽略”或跳过一节:

def main():
    print("This game is the first created by the G.R.R. Digital Entertainment Division.")
    a = input("Welcome to The Forest. It is currently dawn in the middle of a temperate forest. You wake up, unknown of your surroundings. What do you do? ")
    if a == 'Go north' or 'Go North':
        print("You went North until you came to the border of the forest and a pasture. You see house with smoke coming out of the chimney ahead of you, a creek to your right, a meteor coming in from your left, and a forest behind you.")
    elif a == 'Go West' or 'Go west':
        pass
    elif a == 'Go east' or 'Go East':
        pass
    elif a == 'Go south' or 'Go South':
        pass
    elif a == 'Check supplies' or 'Check Supplies':
        print("You currently have a Compass, a dagger, a cyanide pill for suicide, a bottle of iodine, clothes, and a fannypack.")
    elif a == 'suicide' or 'Suicide':
        pass
    else:
        pass

这是你的密码吗?第二次打印缺少结束引号,您也没有代码来遵循
elif
语句。发布堆栈跟踪,告诉您有关错误的信息,以便我们可以看到哪里出了问题。请注意,stackoverflow上漂亮的代码打印为您提供了一个很好的提示,指出了由于颜色错误而导致的错误。考虑使用一个编辑器或IDE来着色并给出关于语法和缩进错误的提示。很抱歉,我忘了这是未完成的产品。(double unfinished本来就在那里)但问题只在于“向东走”的elif语句,而不是其他任何语句。编辑文章以包含错误。在我填充区域之前使用它?因为我现在正在工作,我在第一个If语句中添加了一点,现在第八行的新代码出现了错误。问题是第八行有一个bug,不管该行的代码是什么。是的-如果您对函数/if/循环“无事可做”,请使用
pass
。它检查了python严格的缩进规则。在一些新代码中,问题似乎已经迁移到了第13行。它似乎与“elif”语句有密切关系。请记住,如果一行以冒号结尾,则下一行必须再缩进一级。当您使用完函数/loop/ifI do known后,可以删除该缩进。问题是,这是一个随机出现的问题,尽管第二个if-elif-else语句在第21行中缩进,但它还是迁移到了第21行