<gh_stars>0
#!python3.6
import difflib
from pprint import pprint
import sys

text1 = '''  1. Beautiful is better than ugly.
  2. Explicit is better than implicit.
  3. Simple is better than complex.
  4. Complex is better than complicated.
'''.splitlines(keepends=True)
text2 = '''  1. Beautiful is better than ugly.
  3.   Simple is better than complex.
  4. Complicated is better than complex.
  5. Flat is better than nested.
'''.splitlines(keepends=True)

d = difflib.Differ();
result = list(d.compare(text1, text2))
print('-----')
pprint(result)
print('-----')
print(sys.stdout.writelines(result))

#!python3.6
import difflib
from pprint import pprint
import sys

text1 = '''  1. Beautiful is better than ugly.
  2. Explicit is better than implicit.
  3. Simple is better than complex.
  4. Complex is better than complicated.
'''.splitlines(keepends=True)
text2 = '''  1. Beautiful is better than ugly.
  3.   Simple is better than complex.
  4. Complicated is better than complex.
  5. Flat is better than nested.
'''.splitlines(keepends=True)

d = difflib.Differ();
result = list(d.compare(text1, text2))
print('-----')
pprint(result)
print('-----')
print(sys.stdout.writelines(result))
#!python3.6 1. Beautiful is better than ugly.   2. Explicit is better than implicit.   3. Simple is better than complex.   4. Complex is better than complicated. 1. Beautiful is better than ugly.   3.   Simple is better than complex.   4. Complicated is better than complex.   5. Flat is better than nested.