+ 1
The max function ( Python )
What would happen if you tried to use this function in a list that only contained strings?
2 ответов
+ 4
If you compare two strings, the first letters are compared for their unicode position. If they are equal, then the second letters are compared too, until one letter is 'bigger'.
Now logically, if you apply this to max, the string with the highest value determined by the above routine would be the result.
+ 4
From the docs:
https://docs.python.org/3/tutorial/datastructures.html#comparing-sequences-and-other-types
Python strings are compared lexically.