小编典典

Python-IndentationError:unindent与任何外部缩进级别都不匹配

python

当我编译下面的Python代码时,我得到

IndentationError:unindent与任何外部缩进级别都不匹配

import sys

def Factorial(n): # Return factorial
    result = 1
    for i in range (1,n):
        result = result * i
    print "factorial is ",result
    return result

为什么?


阅读 697

收藏
2020-02-09

共1个答案

小编典典

其他海报可能是正确的…选项卡中可能混有空格。尝试进行搜索和替换,以所有空格替换几个空格。

尝试这个:

import sys

def Factorial(n): # return factorial
    result = 1
    for i in range (1,n):
        result = result * i
    print "factorial is ",result
    return result

print Factorial(10)
2020-02-09