有人能看到此代码中的错误吗?我认为它应该打印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
答案 0 :(得分:5)
two1
中没有任何元素的差异大于10. 9
和1
之间的最大差异为10
因此条件:
abs(int(two1[i+2]) - int(two1[i+3]))>10
总是假的。这意味着第一个和第二个if
都没有被执行,但else
总是被执行。