Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 20th, 2012  |  syntax: None  |  size: 0.31 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import difflib
  2. import os
  3. text1 = input("Enter text: \n")
  4. os.system('clear')
  5. text2 = input("Enter a second text: \n")
  6. os.system('clear')
  7. print("Differences Below:")
  8. print("------------------")
  9. text1 = text1.splitlines()
  10. text2 = text2.splitlines()
  11. d = difflib.Differ()
  12. diff = d.compare(text1, text2)
  13. print("\n".join(diff))