题:给你一个字符串 s,由若干单词组成,单词前后用一些空格字符隔开。返回字符串中最后一个单词的长度。
s
去掉最后一个字符串的空格
str = "luffy is still joyboy" strlist = str.strip().split() print(len(strlist[-1]))
转载:https://leetcode-cn.com/problems/length-of-last-word/