Question: How to code the following: Common Words: Visit Project Gutenberg (http://gutenberg.org/ ) and find a few texts you'd like to analyze. Download the text files

How to code the following:

Common Words: Visit Project Gutenberg (http://gutenberg.org/ ) and find a few texts you'd like to analyze.

  • Download the text files for these works, or copy the raw text from your browser into a text file on your computer.
  • You can use the count() method to find out how many times a word or phrase appears in a string.
  • For example, the following code counts the number of times 'row' appears in a string:

>>> line = "Row, row, row your boat"

>>> line.count('row')

2

>>> line.lower().count('row')

3

  • Notice that converting the string to lowercase using lower() catches all appearances of the word you're looking for, regardless of how it's formatted.
  • Write a program that reads the files you found at Project Gutenberg and determines how many times the word 'the' appears in each text.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a Python program that reads text files from Project Gutenberg counts the number of times the w... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!