See Code
O(?)
class Solution:
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
count = 0
for i in range(len(s)-1,-1,-1):
if s[i] != ' ':
while s[i] != ' ' and i >= 0:
count += 1
i -= 1
break
return count