Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.

If the last word does not exist, return 0.

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

 

相关文章:

  • 2021-07-04
  • 2021-05-24
  • 2021-08-20
  • 2021-12-06
  • 2021-09-11
猜你喜欢
  • 2021-08-21
  • 2021-08-15
  • 2021-10-30
  • 2021-12-24
  • 2021-05-17
  • 2022-01-14
  • 2022-02-08
相关资源
相似解决方案