Question: ` ` ` Objective: read names from two different files into your program and write each name to a single new file. Please make sure

```Objective: read names from two different files into your program and write each name to a single
new file.
Please make sure you download the namelist1.txt & namelist2.txt input files from the assignment page in
Canvas and place them in the same folder as your program:
Input files:
nameslist1.txt & nameslist2.txt -- Each file contains a list of 200 unique names.
Note: before reading each file, you need to read the file name. Your code should work
correctly if input files are renamed!
Output file:
Output all names to an output file
Note: you will need to read the name of the output file.
Write a program that reads the names from the two input files and writes the names to the output file:
a. Ask the user to input the file name and path of the first input file.
i. Use a try/except block to open all input before processing.
ii. If the file cannot be opened, display the appropriate error message, and require the user to
reenter the file name and path.
iii. Continue looping until the user has entered in a valid file name and path.
b. Ask the user to input the file name and path of the second input file.
i. Use a try/except block to open all input before processing.
ii. If the file cannot be opened, display the appropriate error message, and require the user to
reenter the file name and path.
iii. Continue looping until the user has entered in a valid file name and path.
c. Ask the user to input the file name and path of the output file.
i. Use a try/except block to verify that the output file can be created before processing.
ii. If the file cannot be created, display the appropriate error message, and require the user to
reenter the file name and path.
iii. Continue looping until the user has entered in a valid file name and path.
CMSY 156- Lab 6
Files and Exceptions
d. Processing:
i. Use a try/except block to read from the input files and write to the output file.
ii. Read all the names from one input file at a time. Write the names to the output file.
You must use a while loop to process the first input file nameslist1.txt and write to
the output file.
You must use a for loop to process the second input file nameslist2.txt and write to
the output file.
Each line in each input file is one name.
iii. Each name must be written on a separate line in the output file.
iv. There must be no blank lines between names in the output files.
e. All input files and the output file must be closed after all names have been processed.
Rubric: The rubric is located on the assignment page in Canvas. Please review the rubric to
make sure you meet all of the requirements for this lab.
Enter the path and name of the first file: c:\testTerr.txt
Error: file(s) not found, or could not be opened
Please reenter
Enter the path and name of the first file: c:\test
ameslistl.txt
Enter the path and name of the second file: c:\test\err.txt
Error: file(s) not found, or could not be opened
Please reenter
Enter the path and name of the second file: c:\test
ameslist2.txt
Enter the path and name of the output file: c:\test\allnames.txt
Names processing started
Names processing complete
>>>
```
` ` ` Objective: read names from two different

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!