I am trying to compare two files using difflib. After comparing I want to print "No Changes" if no difference detected. If difference is their in some lines. I want to print those line.
I tried like this:
with open("compare.txt") as f, open("test.txt") as g:
flines = f.readlines()
glines = g.readlines()
d = difflib.Differ()
diff = d.compare(flines, glines)
print("\n".join(diff))
It will print the contents of the file if "no changes" are detected. But I want to print "No Changes" if there is no difference.