这是代码段
values_a = [1, -5, 2, 0, 4, 2, -3]
values_b = [1, -5, 2, 4, 4, 2, 7]
answer = 0
for position in range(len(values_a)):
if values_a[position] != values_b[position]:
answer = answer + 1
print answer
答案是2,我不明白为什么 这不是意味着1?
答案 0 :(得分:3)
因为两个值不同:
values_a = [1, -5, 2, 0, 4, 2, -3]
values_b = [1, -5, 2, 4, 4, 2, 7]
^ ^
| |____ boom!
|
______ boom!
0 + 2 == 2