AI engineering glossary · Python core

What is raise?

raise: A statement that deliberately triggers an exception, either a new one or the current one again. It signals an error condition to the caller, for example when the input is invalid.

Level: intermediateTopic: Python core

raise: an example

if age < 0: raise ValueError('age cannot be negative') stops the function with that message.

Related terms

More Python core terms

Where you learn it

raise 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.