2014-09-25 181 views
-2

所以我比较新的Python(2.7)。我写了一个合成部门的代码,它涉及for循环中的while循环,但是当我在终端中执行.py文件时,它显示“IndentationError:unindent不匹配任何外部缩进级别”,指向while循环线。为什么我的while循环在for循环内工作?

下面的代码:

for div in rootlist: 
     dex = 1 
     quot = [poly[0]] 
    while dex != len(poly): 
     quot.append(poly[dex] + quot[dex - 1] * div) 
     dex = dex + 1 

为什么啊,为什么呢? 。:(

+1

它是如何不工作的SyntaxError然后,缩进正确 – falsetru 2014-09-25 14:34:42

+0

其因为'while'压痕 – Kasramvd 2014-09-25 14:35:17

回答

2

在蟒蛇,indentation matters你的代码应该是:??!

for div in rootlist: 
    dex = 1 
    quot = [poly[0]] 
    while dex != len(poly): 
     quot.append(poly[dex] + quot[dex - 1] * div) 
     dex = dex + 1 
+0

哇我错过了!谢谢你,先生!:) – 2014-09-25 14:36:31