Question: IN PYTHON: Write a program that asks the user for the name of a txt file. Also using place holders (hint) The program will read
IN PYTHON:
Write a program that asks the user for the name of a txt file.
Also using place holders (hint)
The program will read a file weather.txt and do the following:
Creates a new file called newtext.txt that contains the original text with all occurrences of the word "whether" replaced with the word "weather", and "weather" replaced with the word "whether". Also, print to the screen each of the words, and the integer that shows the number of times that word appears in the new file.
weather.txt:
Weather the whether be fine,
Or weather the whether be not.
Weather the whether be cold,
Or weather the whether be hot.
We'll whether the whether,
Whatever the whether,
Weather we like it or not.
newtext.txt:
Whether the weather be fine,
Or whether the weather be not.
Whether the weather be cold,
Or whether the weather be hot.
We'll weather the weather,
Whatever the weather,
Whether we like it or not.
After which, printing to the console:
The word "whether" appears 5 times and the word "weather" appears 7 times.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
