Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python 3.6 Question 12 (20 points) Write a function named wordLengths. The function wordLengths takes two parameters: 1. inFile, a string that is the name
Python 3.6
Question 12 (20 points) Write a function named wordLengths. The function wordLengths takes two parameters: 1. inFile, a string that is the name of an input file 2. outFile, a string that is the name of an output file The input file exists when wordLengths is called; wordLengths must create the file outFile. The input file contains only letters and white space For each line of the input file, wordLengths should identify the length of the longest word on the line and how many words of that length there are. It should write the length of the longest word, followed by a space, followed by how many words of that length there are on the line to a corresponding line of outFile. If a line of the input file is empty the corresponding line of the output file should also be empty. For example, if the file zax.txt contains the following lines: There they stood Foot to foot Face to face then the function call wordLengths('zax.txt', 'zaxOut.txt') should produce an output file with the following lines: 5 2Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started