[英]Need help identifying the indentation error in a code block
I tried defining a function below (part of a longer code block), but came across an 'indentation error' identified at the 4th line. 我尝试在下面(一个较长的代码块的一部分)定义一个函数,但是遇到了第四行识别的“缩进错误”。 Could somebody please tell me what the error is?
有人可以告诉我错误是什么吗?
guess = int(raw_input('Your first guess? '))
def next_guess(n):
n -= 1
print "You now have %s attempts left" %n
guess = int(raw_input('Your next guess? '))
Your indentation is a mix of tabs and spaces. 缩进由制表符和空格组成。 The tab character might look like it's four spaces wide in your text editor/IDE, but Python can interpret it as anywhere between one and eight spaces.
在您的文本编辑器/ IDE中,制表符可能看起来像是四个空格,但是Python 可以将其解释为介于1到8个空格之间的任意位置。 This can cause Python to become very confused.
这可能会导致Python变得非常混乱。 Replace the tab on your
n -= 1
line with spaces. 用空格替换
n -= 1
行上的选项卡。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.