user3354259
user3354259

Reputation: 1

Comparing two .txt files showing common words or phrases

I am trying to compare two .txt files and find out every common word in the two (ignoring case sensitivity. If someone could point me towards the right direction that would be helpful. (I don't have any python writing experience, just editing a few scripts)

Upvotes: 0

Views: 1860

Answers (1)

New_User123
New_User123

Reputation: 104

This will give you list containing common words from two files. Output format is list.

with open('a','r') as f, open('b','r') as g:
  l=f.readlines()
  l1=g.readlines()
  print list(set(l)&set(l1))

Upvotes: 1

Related Questions