Built-in Exceptions
ValueError — exception class
An argument has an acceptable type but an invalid value, when no more specific exception fits. Examples include invalid integer text and an out-of-range numeric option. Validate the allowed domain or handle conversion failure. Catch ValueError when this category is the recovery boundary; do not rely on the exact human-readable message.
Formal Syntax & Structure
python syntaxpython
ValueErrorReturn Value
type
The class object ValueError; this reference documents the class identity, not a universal constructor signature.
Working Example
Example Snippetpython
try: int("not a number")except ValueError as error: print(type(error).__name__)