IndentationError:意外缩进Python 3错误

问题描述

使用以下python 3代码

print("The nodes visited in the frontier are:",end = " ")

我收到此错误

IndentationError: unexpected indent

该如何解决

解决方法

正确

if 5 > 2:
  print("Five is greater than two!")

不正确

if 5 > 2:
print("Five is greater than two!")

在此处https://docs.python.org/2.0/ref/indentation.html找到更多信息 或此处(2.1.8。缩进),https://docs.python.org/3/reference/lexical_analysis.html#line-structure

,

我认为您应该在print()之前删除空格。根据您的陈述,我想这很好用

print("The nodes visited in the frontier are:",end = " ")  #removed the space in the beginning