Consider an API that returns four lists as output. Let us consider the conclusion as
a = [1,2,3,4] b = [1,2,3,4] c = [1,2,4,3] d = [1,2,3,5]
Now, first we want to compare these lists, equal or not.
Lists are equal only if elements and indices match. For example, from the above lists, a
and b
are equal. But a
and c
not equal.
If the lists are not equal, then the output is expected as: this element at this index in this list is not the same as the other.
To compare and get the differences in the two lists, I wrote the code below.
for i in range(len(a)): if a[i] != c[i]: print "Expected value at ",i," is ",a[i] print "But got value ",c[i],"in second list"
Now the question is how to achieve this for all four lists?