+ 5
Help me to solve the code #0009
without key its output is 16 and with key its output is 25... i don't understand why..? describe in deatil.. https://code.sololearn.com/c8UDZ4GH7z1o/?ref=app
1 Answer
+ 3
y=['hihi', 'solosolosolosolo', 'learnlearnlearnlearnlearn']
if u print len(max (y))
it will print alphabetical ordered max..
as s is highest amongst h and l
so...
len('solosolosolosolo') which is 16 is the ans
when u print len(max(y, key=len))
it means...max function will word on string length...and return the max length string..
which is...learnleanlearnlearnlearn
=>25..
key tells u on which attribute max function will work on..