Python · Stage 7 – Files and Errors · Lesson 39 of 50

Errors and Exceptions

Read Python error messages and understand why a program stops.

number = int("hello")
Line-by-line explanation
  1. "hello" is text.
  2. int tries to convert it into an integer.
  3. That conversion is impossible.
  4. Python raises a ValueError.

An exception is useful information, not proof that you are bad at programming. It tells you where an assumption failed.