Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2f9a73c

Browse files
Adding a snippet
1 parent b1544bc commit 2f9a73c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,14 @@ def get_vowels(string):
250250
return [each for each in string if each in 'aeiou']
251251
get_vowels('foobar') # ['o', 'o', 'a']
252252
get_vowels('gym') # []
253+
```
254+
### Length of Last Word in a string
255+
This method gets the length of last word in a given string.
256+
```
257+
def lengthOfLastWord(self, s: str) -> int:
258+
if(s.split()):
259+
lst=s.split()
260+
last=lst[-1]
261+
return len(last)
262+
return 0
253263
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /