1
# Rate Our Love !! 

def love(n):
    if n < 0 : 
        print "Why would it be negative?!" 
    elif n == 0 : 
        print "well that is just hurtful" 
    elif n == 1 :
        print "I REALLY love you" 
    elif n == 2 : 
        print "You make me smile at least once, each and every day"
    elif n == 3 : 
        print"you wouldn't believe how annoying it was to get this program to run properly! but it was worth it"
    elif n == 4 : 
        print "let's " + "shoot a little higher than that"
    elif n == 5 : 
        print "you're unforgettable, that's what you are" 
    elif n == 6 :
        print "always have, always '____' *hint* fill in the blank " 
    elif n == 7 :
        print "i could never leave you, I love you too much" 
    elif n == 8 : 
        print "an 8/10 is still only a B, maybe I'm not trying hard enough" 
    elif n == 9 : 
        print " well, I'm not perfect yet, could have seen that one coming. Guess I just have to keep trying :)" 
    elif n == 10 : 
        print " i think you're exaggerating, i really am not that good yet"     
    else:
        print "I still really hope that we could get married someday." 

如果它的格式与此定义的其余部分一样,为什么我会不断收到 n== 7 的缩进错误?

4

1 回答 1

8

尝试运行python -t

如果您混合使用空格和制表符,这将警告您,使其看起来像您具有相同的缩进级别,而实际上您可能没有。

从手册页:

-t
当源文件混合使用制表符和空格进行缩进时发出警告,这种方式使其依赖于以空格表示的制表符的价值。两次给出选项时会发出错误。

于 2013-03-19T02:01:15.967 回答