I have to write the name of the shortest () function, which finds the length of the shortest string in the string list.
The shortest () function takes one parameter: 1. a list of lines, textList
The shortest () function should return the length of the shortest string in the text list. You can assume that textList contains at least one element (string).
For example, the following result will be correct:
>>> beatleLine = ['I', 'am', 'the', 'walrus']
>>> print(shortest(beatleLine))
1
-
When I finished writing the shortest () function, I came up with this solution
def shortest(textList):
return len(max(textList))
string = ['Hey', 'Hello', 'Hi']
print(shortest(string))
But I am confused why the max function returns the length of the shortest function instead of the min function.
If I change max to min, the largest value is returned. It looks like min and max are switching.
I am using Python 3.4 and running it in IDLE.
user5407605