Keywords and Expressions

and — Short-circuit conjunction

Evaluate the left operand and return it immediately if falsy; otherwise evaluate and return the right operand. The result is not necessarily a bool. This makes and useful for guarding an operation, but returning a truthy operand is not the same as computing a Boolean flag. Truth testing can call __bool__ or __len__, and exceptions from evaluated expressions propagate.

Formal Syntax & Structure

python syntaxpython
left and right

Parameters & Attributes

NameTypeDescription
leftobjectFirst operand; truth tested.
rightexpressionEvaluated only when the left operand is truthy.

Return Value

object

The left operand if falsy, otherwise the evaluated right operand.

Working Example

Example Snippetpython
name = "Ada"print(name and name.upper())print(0 and 1 / 0)print(True and False)
Python Reference