Write the output file to that directory

Assignment Help Basic Computer Science
Reference no: EM132270130

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: EM132270130

Questions Cloud

Associated with a cloud-based solution for the business : Show the costs associated with a cloud-based solution for the business? Outline the benefits associated with a cloud-based solution for the business?
Provider based on the functions of the business : Explain new risks associated with using cloud services based on the functions of the business? (detailed answer please)
Write the function named initialletters that takes : Write the function named initialLetters that takes one parameter, wordList - a list of words. Create the return a dictionary in which each initial letter
Write the function named initiallettercount : Write the function named initialLetterCount that takes one parameter, wordList - a list of words. Create the return a dictionary in which each initial letter
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.
Calculate three statistics about in file : Write the function named file_stats that takes one string parameter (in_file) that is the name of an existing text file. The function file_stats should calculat
Controls to address the issues you have identified : Your task is to review the requirements and design proposed along with other relevant information provided, present any potential threats and recommend security
How would each chart differ in representing your data : If choosing between pie chart and a line chart, what factors would you evaluate in choosing which one to use? How would each chart differ in representing
How would you evaluate the risk of your investment : Pick two of the major stock indices; explain what type of companies they represent and discuss what could be the purpose of monitoring those indices.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Major models of ultimate reality

Friedrich Nietzsche and Martin Luther King, Jr. are representatives of 2 major models of ultimate reality:

  Analyze the class performances

Design a data warehouse for a university's gradebook data to analyze the class performances. Suppose the data warehouse  consisting of the following dimensions: department, semester, course, student, instructor, and gradebook; and a set of measures y..

  Personal loan acceptance

Universal Bank is a relatively young bank growing rapidly in terms of overall customer acquisition. The majority of these customers are liability customers (depositors) with varying sizes of relationship with the bank. The customer base of asset c..

  What will be the effect on profit of accepting the order

On the other hand, the company in China is willing to pay only $135 per unit. What will be the effect on profit of accepting the order?

  Rank from smallest to largest the amounts

Rank from smallest to largest the amounts of profit received at these points. Explain your choices, and note whether any point results in a loss.

  Economic exposure to exchange and interest

In 1-2 pgs, explain how the MNC can reduce its economic exposure to exchange and interest rates fluctuations.

  What functions does the ciso perform

What functions does the CISO perform, and what are the key qualifications and requirements for the position?

  Problem regarding the communication technologies

How do you think these communication technologies will affect the travel industry which depends heavily on business-related travel?

  Market behavior or market structure

Should anti-trust law and regulatory agencies focus on market behavior or market structure when addressing market failure due to market

  How would you respond to this new project manager

It seems the easiest way to keep everyone informed is through the use of a monthly newsletter. I will publish the first one in about four weeks and distribute it via e-mail to you and other senior managers within the firm." How would you respond t..

  Display a comic-book style text bubble on the screen

Synchronize the movement of one object to the movement of another

  How could this be feasible and rational

Some economists say that government should instead provide drugs for people in need, how could this be feasible and rational? Is it morally right?

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