Lesson 4 ❮ Lesson List ❮ Top Page
❯ 4.3 Handling Exceptions
⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
EXPECTED COMPLETION TIME
❲▹❳ Video 5m 22s
☷ Interactive readings 5m
✑ Practice 4.3 (G Colab) 10m
When an error occurs, or exception as we call it, Python will normally stop and generate an error message.
These exceptions can be handled using the try and except statement.
In data analysis applications, many functions only work on certain kinds of input. As an example, Python's int function can convert a string to integer, but fails with ValueError on improper input.
When a data that we have is not clean, try and except can be really useful, especially when multiple lists exist. We can assign the value if an error occurred.