Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What is the purpose of a try-except block?
Think about what happens when a program tries to access a file that doesn't exist.
What exception do we catch when a file is not found?
It's a specific error related to files.
What is raised if you try to open a file that doesn't exist?
This is a specific type of error related to file operations.
You should always handle errors specifically. True or False?
Think about the importance of knowing what error occurred.
Create a Python script that reads user input for a filename and tries to read from that file, handling the exception if it does not exist.
Incorporate user input to allow dynamic filename handling.
Write a function that attempts to open a file for writing and logs an error if the process fails.
Utilize the logging module for a professional touch.
5 more questions in this section. Enroll free to practise them all.
Enroll free