|
|
|
|
|
by boredemployee
1108 days ago
|
|
In Python, when comparing lists using the less than (<) operator, the comparison is performed element-wise. The first element of each list is compared, and if they are not equal, the comparison result is determined based on the comparison of the first unequal elements. In this case, [1, 2] and [10, 2] both have different first elements (1 and 10). Since 1 is less than 10, the comparison result is True. The second element of both lists (2) does not affect the comparison result because the first element is already sufficient to determine the outcome. [1, 2] < [10, 2] evaluates to True. |
|
I like that typescript does not rely on an implicit choice, but let’s me express exactly what comparison I care about.