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 a try-except block used for?
Think about how it can prevent crashes.
Name one type of error that can occur when calling an API.
Consider connectivity issues.
What does a try-except block accomplish?
What does it allow the program to do?
True or False: You can only have one except statement in a try-except block.
Consider the flexibility of handling different errors.
Create a Python function that fetches data from an API and handles any potential errors while logging them, returning a default value in case of error.
What do you need to do both in the try and except?
Write a script that attempts to read a file. If the file does not exist, raise a custom exception and log the error.
Think about how custom exceptions help clarify issues.
5 more questions in this section. Enroll free to practise them all.
Enroll free