0
Can someone please explain this?
https://code.sololearn.com/cKTiOFPo1CnB/?ref=app Why is it showing aditya and pratik when there are more bigger and shorter names in the list.
4 Réponses
+ 4
kartik dhingra , it doesn't compare the strings in the list by length. It makes lexicographical comparison.
+ 4
Which means that 'smaller' words are those that come early in a dictionary, and larger ones come later.
Min and max can be reconfigured to measure on a different basis though.
If you want the lengths of the words to be compared, you can do this:
print(
min(friends, key=len),
max(friends, key=len)
)
+ 1
HonFu thank you
0
TheWh¡teCat 🇧🇬 thank you