AI engineering glossary · Python core

What is valueError?

ValueError: A built-in exception raised when a function receives an argument of the right type but an unsuitable value. It is common when converting text to numbers. It is usually caught with try/except when handling user input, so a program can ask again instead of crashing.

Level: beginnerTopic: Python core

ValueError: an example

int('12.5') and math.sqrt(-1) both raise ValueError.

Related terms

More Python core terms

Where you learn it

ValueError is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.