Give you a string s, It consists of several words , Words are separated by some space characters . Returns the length of the last word in a string . word It's just letters 、 The largest substring that does not contain any space characters .
class Solution:
def lengthOfLastWord(self, s: str) -> int:
lst = s.strip().split()
return lst
s = "Hello World"
S = Solution()
result = S.lengthOfLastWord(s)
print(result)