Question: Exercise 4 : reading and writing to file Write a program that reads the content of the file database.txt and replaces all instances of
Exercise : reading and writing to file
Write a program that reads the content of the file "database.txt and replaces all instances of the word "morning" with "evening" all lower case The updated content should be written to a new file called "newdatabase.txt
Just like assignment the word needs to be "morning" by itself. If it is a part of another word such as "morningside" then it shouldn't be replaced.
For example, if "database.txt contains the following content:
Good morning to you!
Good morning to you, residents of morningside!
Then after running the program, "newdatabase.txt should have the following content:
Good evening to you!
Good evening to you, residents of morningside!
For simplicity, you can use split and not worry about punctuations touching the word "morning" such as "morning!"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
