Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago