计算字符串最后一个单词的长度,单词以空格隔开。
一行字符串,非空,长度小于5000。
整数N,最后一个单词的长度。
hello world
5分析:输出字符串长度用len方法;输出最后一个字符串--将字符串变成列表然后用切片[::-1]代码:
str = input() print(len(str.split()[-1]))