def doit(list1, list2):
    lastmatch = -1
    lastunmatch = -1
    for i, x in enumerate(zip(list1, list2)):
        if x[0] == x[1]:
            lastmatch = i                
        else:
            lastunmatch = i
        print abs(lastmatch - lastunmatch)

list1 = ['cat', 'sat', 'on', 'mat', 'xx', 'yy'] 
list2 = ['cow', 'sat', 'on', 'carpet', 'xx', 'yy']

doit(list1, list2)
            
    