class Solution(object): def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ res=s.split() if len(res)!=0: return len(res[-1]) else: return 0