This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
What are three elements that you might find in a traceback?
A file path, line number, and Python version
A Python version, file path, and function name
A file path, line number, and exception
What two keywords would you use for handling exceptions?
try and except
try
except
try and catch
catch
try and unless
unless
Why would using except Exception be unhelpful?
except Exception
Because it can show a traceback with limited information
Because it can hide what the real problem is
Because you can't raise another exception
When can it be useful to use as err in an except block?
as err
When you want to raise another exception
When you want to reuse or inspect an exception
When you want to avoid having a traceback in the output
What is the right syntax to catch two exceptions in the same except line?
raise (ValueError, TypeError)
except ValueError, TypeError:
except (ValueError, TypeError):
You must answer all questions before checking your work.
Was this page helpful?