Question: Question 12 (20 points) Write a function named wordCount that counts how many words there are in each line of an input file and writes

Question 12 (20 points) Write a function named wordCount that counts how many words there are in each line of an input file and writes that count to a corresponding line of an output file. The input file already exists when wordCount is called. wordCount creates the output file Input. The function wordCount takes two parameters i. inFile, a string that is the name of a text file that is to be read and analyzed. The file that inFile refers to contains only upper and lower case letters and white space (no punctuation marks or other special characters) outFile, a string that is the name of the file to which wordCount writes its output. ii. The input file is in the current working directory and you should create the output file to that directory. Output. For each line of inFile, wordCount should write a corresponding line to outFile containing a single integer: the number of words on the line If the content of the file catInTheHat.txt is below, The sun did not shine It was too wet to play So we sat in the house All that cold cold wet day I sat there with Sally We sat there we two And I said How I wish We had something to do the function call wordCount ('catInTheHat.txt, 'catInTheHatOut.txt') should create a file named catInTheHatOut.txt with this content: 5 6 6 6 5 5 6 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
