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,868評論 0 23
  • 背景 一年多以前我在知乎上答了有關LeetCode的問題, 分享了一些自己做題目的經驗。 張土汪:刷leetcod...
    土汪閱讀 12,769評論 0 33
  • 有姑娘來問我,如果一個人要我等,才會結婚,我要不要等。我想說,給自己一個時間期限,別消耗自己太久,時光經不起消逝,...
    YIBAO閱讀 716評論 6 9
  • 翻譯自這里 selector 是一個對象(object)選擇執行某個方法的名稱,或者是代碼編譯后用來唯一標識一個方...
    huiyuM閱讀 212評論 0 0
  • 星期日/晴加大風 我竟然......竟然四天沒有寫日記了?!看到記錄的一瞬間我是懵逼的,還以為只有昨天太困沒腦子寫...
    酒久里個丸子閱讀 336評論 0 0