Write the output file to that directory

Assignment Help Basic Computer Science
Reference no: EM132271659

Write the function named repeat_words that takes two string parameters:

1. in_file: the name of an input file that exists before repeat_words is called

2. out_file: the name of an output file that repeat_words creates

Assume that the input file is in the current working directory and write the output file to that directory.

For each line of the input file, the function repeat_words should write to the output file all of the words that appear more than once on that line. Each word should be lower cased and stripped of leading and trailing punctuation. Each repeated word on a line should be written to the corresponding line of the output file only once, regardless of the number of times the word is repeated.

For example, if the following is the content of the file catInTheHat.txt:

Too wet to go out and too cold to play ball.

So we sat in the house.

We did nothing at all.

So all we could do was to Sit! Sit! Sit! Sit!

The following function call:

inF = 'catInTheHat.txt'

outF = 'catRepWords.txt'

repeat_words(inF, outF)

should create the file catRepWords.txt with the content:

too to

sit

Hint: Be sure to test your solution with input in which some repeated words on a line are a mixture of upper and lower case, and in which repeated words sometimes are preceded or followed by punctuation.

Reference no: EM132271659

Questions Cloud

Key and the corresponding value : Create the return a dictionary in which each initial letter of a word in wordList is a key and the corresponding value is a list of the words in wordList
Product life cycle philosophy be detrimental or beneficial : In terms of product management, can following the Product Life Cycle philosophy be detrimental or beneficial?
Create the return a dictionary : Create the return a dictionary in which each initial letter of a word in wordList is a key and the corresponding value is the number of words in wordList
Identify a facility management issue from the viewpoint : The research paper will identify a facility management issue from the viewpoint of a hotel general manager.
Write the output file to that directory : Assume that the input file is in the current working directory and write the output file to that directory.
Draft corporate usage policy for use of instant messaging : You have been asked to draft a corporate usage policy regarding the use of instant messaging. The policy should encourage the use of IM and chat while also.
Health care in urban areas and for low-income public : Pretend that this Policy: Health care in Urban Areas and for Low-Income public in California, has been accepted by the committee,
Write an effective response to a common business scenario : The purpose of this paper is to demonstrate your ability to use your chosen medium to write an effective response to a common business scenario.
Print the three statistics on separate lines : Write the function named file_stats that takes one string parameter (in_file) that is the name of an existing text file. The function

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Loop structure that continues to square the number

Obtain an integer value between 1 and 9 from a user. create a loop structure that continues to square the number until the result exceeds 1,000,000.

  Need a flow chart /blue print showing all the steps

Need a flow chart /blue print showing all the steps below is in the process - ordering a drink at our large pools 1. customer wants drink

  How you think fox lake should proceed

Using Figure 10-13 as a guide, develop a plan for implementing the process in Figure 10-9. Ignore the Collect Deposit activity. Assume that it has been developed and works.

  Evaluate the functionality of content delivery networks

Investigate and evaluate the functionality of Content Delivery Networks (CDNs.) Find and use a minimum of five technical resources from creditable sources.

  Why would this implementation be better than original one

If there were more passes than fails, why would this implementation be better than the original one?

  Administrator needs to re-enable the settings

Then, when the tasks are complete, the administrator needs to re-enable the settings in the local policy. How could this system be improved?

  Identify a machine you have used that had a machine guard

With these requirements in mind, identify a machine you have used that had a machine guard to protect the operator or other person in the machine area from hazards. Sketch the machine and label the guarding device, power source, point of operation..

  Mobile growth is about to be staggering

After reading the article, Mobile growth is about to be staggering (click on title to access the article), discuss the implications as related to business LANs

  Writesql statement produce single column called itemlocation

Write an SQL statement to produce a single column called ItemLocation

  Advantages and disadvantages of information system

What would the advantages and disadvantages of the information system be? Identify the type of information system this would represent. What ethical problems might this type of system introduce? Provide at least 2 examples of potential problems.

  What the service provides

What the service provides. - Type of service (SAAS, PAAS, IAAS), it may be more than one. Justify your assessment using the NIST definitions. - Does it meet the 5 essential characteristics of cloud computing listed by NIST. Justify your assessment.

  Number of additional people

where x is the number of additional people above 25. Find the marginal revenue if the group contains 30 people. Interpret your result.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd