题目描述:
Simple, given a string of words, return the length of the shortest.word(s).
String will never be empty and you do not need to account for different data types.
很简单,给定一串单词,返回最短单词的长度。
字符串永远不会为空,您不需要考虑不同的数据类型。
解题思路:
将字符串分解成单词组成的列表,min()找出列表中最短单词,参数key=len。
代码实现:
def find_short(s):
# your code here
temp=s.split()
l=len(min(temp, key=len))
return l # l: shortest word length