Tuple direct comparison in Python

Hi,

Referring to tuple direct comparison examples in the session, could you please help me out to understand how internally python compares the tuples

(0,1,2) < (5,1,2) - True
(here 0 < 5 is True, 1 < 1 is False, 2 < 2 is False, but why result is True

Similarly in the below case as well
(0,1,2000000) < (0,3,4) - True

Thanks
Raghav

It goes to compare the second value only if the first values are equal and it goes to compare third value only if the first and second values are equal.

Thanks Sandeep,

In fact there was clarification on this topic in your subsequent session like tuples are compared just like strings (lexical)

If the first element of both tuple are same then comparison proceed to next element

P.S : In net we can’t find any clear explanation on this, Thank You

1 Like