Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Operator >

Tests strict descending order between comparable operands.

Version: Python 3.14; repository image, production runtime not attested

Syntax

left > right

Tests strict descending order between comparable operands.

A strict lower-bound test excludes the boundary. Lists and tuples of comparable items can be ordered lexicographically, which is useful for multi-part sort keys.

If equal prefixes extend to the end of one sequence, the longer sequence is greater. Unrelated built-in types such as integers and strings have no shared ordering.

Lists compare corresponding elements until the first difference determines their order.

Syntax

left > right

__gt__, __lt__ · TypeError

Worked example

[1, 2, 0] > [1, 2] → True
3 > 3 → False

Examples

print(7 > 7)
print([1, 9] > [1, 2, 8])

Result

False
True

Lists compare corresponding elements until the first difference determines their order.

Sources