Question: Open the file provided file for reading. Create a loop to move through each line of the file contents in order to determine if the

Open the file provided file for reading.
Create a loop to move through each line of the file contents in order to determine if the current number is even or odd. Based on the findings, build two string variables contain a list of even and odd numbers. Add a "
" to the end of each number
Close the file after the loop ends.
Open two new files for writing and write the odd numbers to one and the even numbers to the other
HINT: Use the modulo operator % with a 2 to determine if the current number is even or odd.
Additional Instructions:
All of your code should reside inside of a TRY/Except code block. Check for a "FileNotFoundError" error.
Do not shortcut the steps. Do not write the numbers to the two new odd/even files inside the same loop where you're reading from the provided file. Write your code to follow the sequence of steps "as listed" in the instructions.
There's no need to loop through the two variables. You can just write the variable content to their respective files in a single line. Don't forget to close the files afterwards.

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 Databases Questions!