Files
leetcode/58-length-of-last-word/58-length-of-last-word.py
T

9 lines
201 B
Python

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