Python · Exceptions

ValueError

Raised when a value has the right type but an invalid value.

Syntax
raise ValueError("…")

Example

Open in the lab

More in this group

FileNotFoundError IndexError KeyError TypeError ZeroDivisionError

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course