-2

任何人都可以看到此代码中的错误吗?我认为它应该打印 two1[i],但它什么也没打印。

two1=[1,2,10,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
count = 0
i = 0
while count < 4:
    #if i == len(two1)-6: break
    #else:
        if abs(int(two1[i+2]) - int(two1[i+3]))>10 and abs(int(two1[i+4]) -abs(int(two1[i+5]))<10  
            print two1[i]
            count = count + 1
            i = i + 6
        if abs(int(two1[i+2]) - int(two1[i+3]))<10 and abs(int(two1[i+4]) -  abs(int(two1[i+5])) > 10:


            print two1[i]
            count = count + 1
            i = i + 6
        else:
            count = count + 1
            i = i + 6
4

1 回答 1

5

没有任何元素two1的差异大于 10。最大差异是9between110因此条件:

abs(int(two1[i+2]) - int(two1[i+3]))>10

总是假的。这意味着第一个和第二个if都不会被执行,但else总是会被执行。

于 2013-05-19T20:46:51.053 回答