0

Below are the two lists of tuples:

text1_lines = [('a','1'), ('b', '2'), ('c','3')]
text2_lines = [('a','4'), ('z', '5'), ('c','6')]

I can get the differences with below code

d = difflib.Differ()
diff = d.compare(text1_lines,text2_lines)
diff_list = '\n'.join(diff)

Please suggest how can I convert diff_list into a list, so that I can iterate through the list.

Andrii Litvinov
  • 12,402
  • 3
  • 52
  • 59
Ron
  • 51
  • 1
  • 1
  • 5

1 Answers1

0

Got it.

d = difflib.Differ()
diff = d.compare(text1_lines,text2_lines)
diff =  list(diff)
for item in diff:
    print(item)
Ron
  • 51
  • 1
  • 1
  • 5