001. Codewars 之 Shortest Word 解法

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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,921评论 0 23
  • 背景 一年多以前我在知乎上答了有关LeetCode的问题, 分享了一些自己做题目的经验。 张土汪:刷leetcod...
    土汪阅读 12,775评论 0 33
  • 有姑娘来问我,如果一个人要我等,才会结婚,我要不要等。我想说,给自己一个时间期限,别消耗自己太久,时光经不起消逝,...
    YIBAO阅读 717评论 6 9
  • 翻译自这里 selector 是一个对象(object)选择执行某个方法的名称,或者是代码编译后用来唯一标识一个方...
    huiyuM阅读 212评论 0 0
  • 星期日/晴加大风 我竟然......竟然四天没有写日记了?!看到记录的一瞬间我是懵逼的,还以为只有昨天太困没脑子写...
    酒久里个丸子阅读 336评论 0 0