
class Solution:
"""
@param s: A string
@return: the length of last word
"""
def length_of_last_word(self, s: str) -> int:
# write your code here
if not s:
return 0
right = len(s) - 1
count = 0
while s[right] == " ":
right -= 1
continue
for i in range(right,-1,-1):
if s[i] != " ":
count += 1
else:
return count
return count