缩进错误:未缩进与任何外部缩进级别都不匹配

  • 问题:
  • 当我编译下面的Python代码时,我得到

    缩进错误:未缩进与任何外部缩进级别都不匹配

    import sys

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

    为什么?在

  • 答案:
  • 其他的海报可能是正确的…你的标签上可能有空格。尝试执行搜索和替换,将所有选项卡替换为几个空格

    试试这个:

    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)