【发布时间】:2016-01-27 11:46:42
【问题描述】:
你好,这是我的 python 代码:
def is_palindrome(nombre):
if str(nombre) == str(nombre)[::-1]:
return True
return False
x = 0
for i in range(100, 1000):
for j in range(i, 1000):
for z in range(j, 1000):
produit = i*j*z
if is_palindrome(produit):
if produit > x:
x = produit
print(x)
当我试图编译这段代码时,我得到了这个错误: 产品 = ijz ^ IndentationError: unindent 不匹配任何外部缩进级别 请问有人有想法吗??
【问题讨论】:
-
我知道这个问题:unindent 不匹配任何外部缩进级别。缩进在 Python 中很重要,所以你必须修复它。检查每个级别使用了多少空间,检查是否有标签,等等。
-
事实上:程序正在运行,但是当我在 range(j, 1000) 中添加 z 时:我将 i 和 j 乘以 z 我得到了错误
-
我不明白为什么
-
因为您添加的代码使用了不匹配的缩进级别。如果不能保证您发布的代码完全匹配程序中的缩进,我只能这么说。
-
现在看来,
produit = i*j*z行的缩进显然是错误的
标签: python python-2.7 python-3.x wxpython ipython