I tried with max
and min
but it didn't work as expected. For example from the following list:
ejemplo = ["casa", "parque", "dog"]
The method, if it exists, should return the longest element:
parque
And the smallest is:
dog
I tried with max
and min
but it didn't work as expected. For example from the following list:
ejemplo = ["casa", "parque", "dog"]
The method, if it exists, should return the longest element:
parque
And the smallest is:
dog
The easiest way using
max()
andmin()
and setting that key to get these values from the functionlen()
:Note: Keep in mind that this will only return a single minimum or maximum value, if you wanted to get all the ones that meet that condition, you could do: