Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to find the occurrences of names in a text document contains a paragraph  RSS feed

 
Nagaraj Shivaklara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can you please help me with this?

I have 2 files, 1. Words.txt (Contains some words) 2. Data.txt(Contains a paragraph); I need to find out and display for each word listed in Words.txt appeared in Data.txt.

Can you please help me with the logic??

Thanks
Nagaraj
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put all the words from data.txt into a Set. Check if each of the words in words.txt is in the Set.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!