Documentation

Type defined in library builtins

ValueError

Python raises a value error when an operation receives an argument that has the right type but an inappropriate value.

Some situations that look like value errors are not reported as value errors, but as other kinds of errors. For example, a divison by zero is reported as a zero division error.

Note that the text of the error message depends on the implementation. Different versions of Python and different checking tools will give slightly different messages.

Code
rectangle(-10, 10, red)
error
ValueError: Invalid length for parameter `width`
Code
triangle(200, 50, 50, red)
error
ValueError: Value for parameter `angle` out of the allowed range [0, 180]
Code
sqrt(-1)
error
ValueError: math domain error

Logo of PyTamaro

PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI

Privacy PolicyPlatform Version a9143b0 (Sun, 14 Dec 2025 12:09:46 GMT)