Pythonic way to compare two lists and print out the differences

comparison, python

Solution

list1=[1,2,3,4]
list2=[1,5,3,4]
print [(i,j) for i,j in zip(list1,list2) if i!=j]

Output:

[(2, 5)]

Edit: Easily extended to skip n first items (same output):

list1=[1,2,3,4]
list2=[2,5,3,4]
print [(i,j) for i,j in zip(list1,list2)[1:] if i!=j]

Problem

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 match. The way I am doing it is like this ``` i = len(list1) if i == 1: print 'Nothing to compare' else: for i in range(i): if not (i == 0): if list1[i] != list2[i]: print list1[i] print list2[i] ``` Is there a better way to do this? (Python 2.x)

Original source