x 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.
def find_short(s):
# your code here
return l # l: shortest word length
Solution:
def find_short(s):
word_list = s.split()
len_list = []
for word in word_list:
len_list.append(len(word))
l = min(len_list)
return l
网友评论