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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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