The objective of this programming assignment is to modify an existing text file, replacing words. All you have to turn in is the Python code.

This assignment will incorporate the conditional and repetition patterns you have done previously, and also incorporate file input/output and exception handling.

Starting with a plain text file, which you can create using Notepad or other common text editing tool, create a file that contains some simple text. An easy way to do this is to use a common website, such as this one. Many web developers use such sites to create placeholder text as a stand-in until a copy editor replaces it with the actual text later. Feel free to create your own text file. Note: do NOT use editors such as Microsoft Word, WordPad, and the like, because files like .doc or .docx are not plain old text files and won't work for this assignment.

Write a Python program that:

Ask the user for a filename
Verify that the filename exists or print an error and stop if it doesn't exist
Open the file (remember to catch any exceptions that might be thrown, and print an error if that happens)
Ask the user for two words, the search word and the replacement word
Read each line of the file, and for each line, see if it contains the search word. If it does, replace it with the replacement word. Hmmm, how do we do that? One pattern is to create a new string concatenating what comes before the search word, the replacement word, and what comes after the search word.
Hmmm, how do we "replace" the line in the file? One pattern is to create a new file, write the lines to the new file as we read them, and if the search word appears, write the modified line to the new file instead of the original line. Then when we are finished, close both files and rename the new file with the original file's filename. Tricky? Hey, this is how every program on your computer must handle files!
Since we are comfortable doing assignments, let's polish it up this time and make it look professional.

Include comments at the top of your Python code file with your name, the class, and a brief assignment description.
Display a nice prompt message at the beginning of the program with the title and version.
Comment your Python code appropriately.
Before exiting, display a nice message that thanks the user for using your program and report how many lines were modified.
Testing (be sure to test your code):

What happens if the filename entered doesn't exist?
What if the file exists, but is opened in an editor?
What if the search word isn't found in the file?
What if the search word appears twice on the same line?
What to turn in:

Python code in a .py file