[Tutor] How to compare text?
Mon, 03 Dec 2001 05:14:25 -0500
On Mon, Dec 03, 2001 at 11:06:04AM +0100, A wrote:
> How can I compare of one parragraph of text with another
> paragraph?Each paragraph can have about 100 words.
> For example I have the first paragraph
> I want to be very good at Python programming. Better than in Perl.
> THe second paragraph might look loke this:
> She works all day long to master Perl.
> All that I need is to find out if any of word from the second is in the
> first paragraph. For the example above I should find out word
> What is the best and quickest way?
Something along these lines:
paragraph1words = paragraph1.split()
paragraph2words = paragraph2.split()
common_words = 
for word in paragraph1words:
if word in paragraph2words:
print "These words are in both paragraphs:",
for word in common_words:
> Thank you for help.
> Tutor maillist - Tutor@python.org
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org