1

Strings are compared lexicographically.

In this example the first 2 corresponding 9s will be compared but after that what is compared against 1?

>>> '99' > '991'
False
Mohammad Yusuf
  • 16,554
  • 10
  • 50
  • 78
  • 1
    Nothing, size matters. – ForceBru Dec 28 '16 at 11:52
  • 3
    It seems the [*"until either sequence is exhausted"*](https://docs.python.org/3/tutorial/datastructures.html#comparing-sequences-and-other-types) part explains it (see http://stackoverflow.com/a/4806946/3832970). – Wiktor Stribiżew Dec 28 '16 at 11:52
  • 1
    What Wiktor said: "If one sequence is an initial sub-sequence of the other, the shorter sequence is the smaller (lesser) one. " – PM 2Ring Dec 28 '16 at 11:54
  • In a dictionary, would you expect "dental" to come before "dent"? Lexicographical order in programming is hopefully consistent with the natural lexicographical order. – Right leg Dec 28 '16 at 12:12

0 Answers0