Python list greater than number [duplicate]

In this case of “mismatched” types, the types are listed lexicographically by type name: a “list” comes after an “int” in alphabetical ordering, so it is greater.

CPython implementation detail: Objects of different types except
numbers are ordered by their type names; objects of the same types
that don’t support proper comparison are ordered by their address.
(source)

There is no language specification for the ordering (apart from the fact that it is consistent). It just happens to be the case that CPython is the most common implementation in which there is this language detail of being ordered lexicographically by type names.

Leave a Comment