I have two lists which are guaranteed to be the same length. I want to compare the corresponding values in the list (except the first item) and print out the ones which dont mat
Noting the requirement to skip the first line:
from itertools import izip
both = izip(list1,list2)
both.next() #skip the first
for p in (p for p in both if p[0]!=p[1]):
print pair
zip
, to generate an iterator through pairs of values. This way you don't use up a load of memory generating a complete zipped list. both
iterator by one to avoid processing the first item, and to avoid having to make the index comparison on every step through the loop. It also makes it cleaner to read.