Python newbie here. I have the following code to compare two strings using difflab library. The output is prefixed with ‘+’,’-‘ for words which are different. How to get only the differences printed without any prefix? The expected output for the below code is Not in first string: Nvdia Not in first string: IBM Not in second string: Microsoft Not
Tag: difflib
Why do I get a stray element with difflib.ndiff?
Minimal working example: Can someone please explain why there’s a newline character as the fourth element in the output list? What can I do to not get that element as ndiff output, but only the rest of the list? Answer Because ndiff expects the lines you pass in to end with newline characters, like this: In the docs for difflib.Differ.compare,