美文网首页
001. Codewars 之 Shortest Word 解法

001. Codewars 之 Shortest Word 解法

作者: 伟健Wiken | 来源:发表于2017-02-28 15:15 被阅读0次

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

相关文章

网友评论

      本文标题:001. Codewars 之 Shortest Word 解法

      本文链接:https://www.haomeiwen.com/subject/eopxgttx.html