Chapters
Python114 chapters

ReferenceException types

ValueError

The type is right but the value is impossible.

Signature

ValueError(message)

Returns

Raised by conversions and by your own validation.

Example

Python
try:
    int("abc")
except ValueError as problem:
    print("ValueError:", problem)

Output

ValueError: invalid literal for int() with base 10: 'abc'

See also