Question: Write a program that first asks the user for the names of input and output files. For each line in the input file, the program

 Write a program that first asks the user for the names

Write a program that first asks the user for the names of input and output files. For each line in the input file, the program should write to the output file the number of times the line contains "the" or "The followed by the line itself as it is. A sample input file (PAS_input.txt) and its corresponding output file (PA5_output.txt) are posted. Note: The program will count all occurrences of "the" or "The" including when they are part of another word, for example, "these". Hint: Use the string's count() function. If you find that your program prints an extra line for every line then you may need to remove the newline character from each line, for example, by using the string's rstrip() function. The program will run like this: >>> import PAS_solution Give the name of the input file: PA5_input.txt Give the name of the output file: PA5_output.txt Output has been written to PA5_output.txt >>>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!