Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING PYTHON 3 Using a try-except, write code to a file from the user. If the user gives a file that cannot be opened then

USING PYTHON 3

image text in transcribed

Using a try-except, write code to a file from the user. If the user gives a file that cannot be opened then warn the user. Otherwise, output the contents of the file. Note Remember you should catch the specific exception that occurs when you can't open the file. FileNotFoundError Note2-Don't forget to close the file. Successful input (1 pt) Enter a valid file input.txt The contents of the file was Great work. Invalid Input (3 pts) Enter a valid file Bad input File Bad input could not be opened. Try again. Enter a valid file: invalid input File invalid input could not be opened. Try again. Enter a valid file input.txt The contents of the file was Great work

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions