We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 43afb18 commit d1643bbCopy full SHA for d1643bb
leetcode-058/leetcode058.py
@@ -0,0 +1,11 @@
1
+class Solution:
2
+ def lengthOfLastWord(self, s: str) -> int:
3
+ newStr = s.strip()
4
+ lastSpacePos = newStr.rfind(' ')
5
+ if lastSpacePos == -1:
6
+ return len(newStr)
7
+ else:
8
+ return len(newStr) - lastSpacePos - 1
9
+
10
+sol = Solution()
11
+print(sol.lengthOfLastWord('Hello my baby'))
0 commit comments