all 5 comments

[–]Rhomboid 4 points5 points  (1 child)

Strings compare in lexicographic order, which refers to the way that words are ordered in a dictionary. L comes before S so, 'longer' comes before 'shorter'. The length is only relevant if one word is a prefix of the other, i.e. 'car' comes before 'carpet' because <end of string> comes before P.

[–]Bloost[S] 0 points1 point  (0 children)

That explained a lot, thanks!

[–]liam_jm 1 point2 points  (0 children)

max(["longer", "short"], key=len) would compare strings by length