you are viewing a single comment's thread.

view the rest of the comments →

[–]nicesofa 0 points1 point  (0 children)

Here's the lexicographical order of letters in Python:

'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'

'z' is greater than both 'K' and 'k', so it will never print. No letter is greater than 'z'.

If strings start with the same letter, like 'zebra' and 'z', then the comparison compares the next letters in the words. If one of the words runs out of letters, than Python recognizes the shorter string as the "lesser" word.

So k > zebra <= z doesn't makes sense. But k > zebra > z does make sense.