输出字符串中最后一个单词的长度
if not s: print(0) else: i = 1 n = 0 while i <= len(s) and s[-i] == ' ': i = i + 1 while i <= len(s) and not (s[-i] ==' '): i = i + 1 n = n + 1 print(n)
输出字符串中最后一个单词的长度
if not s: print(0) else: i = 1 n = 0 while i <= len(s) and s[-i] == ' ': i = i + 1 while i <= len(s) and not (s[-i] ==' '): i = i + 1 n = n + 1 print(n)