When using the comparison operators <
, <=
, >
, >=
on two iterables* (at least for strings, lists ans tuples), Python do not compare its lengths but compares them in a lexicographical order. It means that it compares each item of one iterable with the item of the other that is in the same position. So in your example Python compares:
'computador' > 'computador' (false since they are the same)
'caderno' > 'celular' (false because the letter 'a' of caderno comes first than the letter 'e' of celular)
'lapiseira' > 'café' (true because the 'l' of lapiseira is greater of the 'c' of café)
'caneta' > 'água' (false because the 'c' of caneta is not greater than the 'á' (note the accent mark) of água)
Python actually only does the comparisons until it is no longer truth, so it stops comparing in 'computador' > 'computador'
. I just put the four of them to illustrate how it works.
So for the comparison a > b
it returns False
(*) Not every iterable supports comparisons using the operators mentioned above. They must be implemented to be used like that. Python lets you use this behavior by default (as far as I know) only in strings, tuples and lists.
With set
instances, for example, it has a completely different behavior