How to get string of pair data?
I have two pair data, float1 and str1, float2 and str2, I get max float
max() with key argument python
I know a bit about how key
argument is used in python max()
. max(("pyth", "lua", "ruby"), key=len)
will return pyth
and ruby
. However, max((31, 13, 11), key=lambda x: sum(int(i) for i in str(x)))
will only give me 31
(13
should be returned as well), or max((13, 31, 11), key=lambda x: sum(int(i) for i in str(x)))
will only give me 13
(31
should be returned as well). Can someone explain this? Many thanks.