f1 = open('/Users/wm/coding/1') f2 = open('/Users/wm/coding/2') row = 0 for (line1,line2) in zip(f1,f2): row += 1 if line1 == line2: pass else: col = 0; print row for (a,b) in zip(line1,line2): if a == b: col += 1 else: pass print col, f1.close() f2.close()