Question
IN PYTHON: Write a program that asks the user for the name of a txt file. The program will read a file weather.txt and do
IN PYTHON:
Write a program that asks the user for the name of a txt file.
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
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