AI engineering glossary · Python core
What is truthiness?
Truthiness (also called truthy and falsy): The way Python treats any object as true or false when a boolean is needed. False, None, zero, and empty containers or strings are falsy; almost everything else is truthy. It allows concise checks such as if items:.
Truthiness: an example
if []: is false and if 'hi': is true. name = user_input or 'guest' uses 'guest' when the input is an empty string.
Related terms
More Python core terms
Where you learn it
Truthiness is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.