python字符串最後一個單詞的長度華爲機試筆試部分牛客網第1題

題目描述 計算字符串最後一個單詞的長度,單詞以空格隔開。  python 輸入描述: 一行字符串,非空,長度小於5000。spa 輸出描述: 整數N,最後一個單詞的長度。code 示例1 輸入 hello world 輸出 5 python3 str=input() for i in range(len(str)): if str[len(str)-1-i]==' ': c
相關文章
相關標籤/搜索