본문 바로가기

IT/코딩테스트

[Leetcode] 58. Length of Last Word

728x90

 

class Solution:
    def lengthOfLastWord(self, s: str) -> int:
        s = s.rstrip().split(" ")
        return len(s[-1])

https://leetcode.com/problems/length-of-last-word/description

 

728x90