Saturday, August 2, 2025

Showing differences between contents of 2 files

with open("Bart.txt") as bart:

  L = bart.readlines()


with open("Joshua.txt") as joshua:

  L1 = joshua.readlines()


ctr = 0

for i in range(len(L)):

  if L[i] != L1[i]:

    ctr += 1

    print(L[i])  # Print differing line of File 1

    print(L1[i]) # Print differing line of File 2

    input()

print(ctr)


No comments:

Post a Comment