超级烦人的缩进错误(Python)

时间:2011-08-15 22:59:52

标签: python indentation

经典的意外缩进错误。这是相关的代码。问题是如何解决它?

    def getNum():
        firstNum = input("Please state what number to start at: ")
        secondNum = input("Please state swhat number to end at: ")
        if countingSubmenu == 3 or countingSubmenu == 4:
            thirdNum = input("Please state what increment you would want to go up by: ")
            return firstNum, secondNum, thirdNum
        else:
            return firstNum, secondNum

    if option == 1:
        getNum(firstNum, secondNum, thirdNum)
        for x in range(firstNum, secondNum+1, 1):
            print x
        print "End of test." #def getNum():

1 个答案:

答案 0 :(得分:3)

这三行是​​使用制表符而不是空格:

            return firstNum, secondNum, thirdNum
        else:
            return firstNum, secondNum

您可以通过尝试编辑问题轻松看到这一点,标签显示的宽度为8个空格。