Operators

< — Strict less-than

Tests strict ordering. Built-in strings compare lexicographically by code point, and comparable lists and tuples compare at their first differing element. For sets this means proper subset, not a size comparison or total order. Complex numbers and dictionaries do not support ordinary order comparisons. Rich comparisons share precedence and support chaining: the middle operand is evaluated once, and later operands are skipped when a preceding comparison is falsy. If both operands decline the comparison, ordering raises TypeError. Custom dispatch uses __lt__ and the counterpart __gt__ on the other operand; a right-hand subclass may have priority.

Formal Syntax & Structure

python syntaxpython
left < right

Parameters & Attributes

NameTypeDescription
leftobjectFirst operand; its type participates in operation selection.
rightobjectSecond operand; supported values depend on the operand types.

Return Value

bool or custom result

Boolean for ordinary built-in comparisons; custom rich comparison methods can return other values.

Working Example

Example Snippetpython
print(3 < 5)print([1,9] < [2,0])print({1} < {1,2})
Python Reference