the problem in your logic seem to be with nsX buffers you use inside the for loop, after failing the condition there is no reset in them so they can check other values since the carry along the mismatch from the first index.
Also it is easier to use
zip() to iterate over the lists at the same time instead of using indexes and
range() which should be avoided so your main loop can become like this:
for x, y in zip(lst3, lst4): ns3 = ns3 + x ns4 = ns4 + y if ns3 == ns4: match2 = match2 + 1 else: ns3 = '' ns4 = ''
In your case i don’t see anything done with the digits being consecutive, which can simplify your problem to which letters are the same in the same index of the lists, a much simpler check that can be done like this
count = sum(x == y for x, y in zip(lstx, lsty))
here zip() is used to itarate over both of the lists at the same time and the fact that sum() can sum values of false and true is used to to get how many times the condition x == y is true
CLICK HERE to find out more related problems solutions.