题解 | #字符串最后一个单词的长度#

字符串最后一个单词的长度

http://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da

str = input() list = [] i = 0 s = 0 while i < len(str): s = i while str[i] !=" " and str [i] not in[".",","]: i += 1 if i == len(str): break list.append(str[s:i]) if i == len(str): break while str[i] ==" " or str[i] in [".",","]: i += 1 if i == len(str): break

print(len(list[-1]))

全部评论

相关推荐

昨天 14:32
已编辑
上海应用技术大学 运营
青春运维少年不会梦到...:实习大王
点赞 评论 收藏
分享
gelmanspar...:奖学金删掉,自我评价删掉,简历压缩一下,写一页
如果再来一次,你还会学机...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务