题解 | #字符串最后一个单词的长度#
字符串最后一个单词的长度
http://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
st = input()
lenth = 0
if st.find(' ') >= 0:
for i in range(len(st)-1, -1, -1):
if st[i] == ' ':
print(lenth)
break
else:
lenth = lenth + 1
else:
print(len(st))
lenth = 0
if st.find(' ') >= 0:
for i in range(len(st)-1, -1, -1):
if st[i] == ' ':
print(lenth)
break
else:
lenth = lenth + 1
else:
print(len(st))