Question
9.8LAB: Input-Output Exceptions: Getting a Valid File In this exercise you will continue with exception processing for file input-output. You should extend the program developed
9.8LAB: Input-Output Exceptions: Getting a Valid File
In this exercise you will continue with exception processing for file input-output. You should extend the program developed in lab 9.7 that includes exception handling for non-existent files. To do this, you will need a loop that continues to prompt the user for file names until a valid file name (when opening it) occurs. In this case, your try-except will be inside the loop.
(1) Make sure that your program works correctly with "data.txt". (2pts)
(2) Test your program with the loop and a try-except to handle an incorrect name of a file name and continue to prompt the user until a valid file is entered. (8 pts)
For example, if you enter the name of a file "data", your program should output:
Enter name of file: File data not found. Enter new file name: File to be processed is: data.txt Average weight = 164.88 Average height = 69.38
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started