Last Word Length
When working with text, you often need to extract the final part, such as the last word in a title or message. Given a string s made of words and spaces, return the length of the last word. A word is the final continuous run of non-space characters.
Примеры
Ввод
"Hello World"Вывод
5Ввод
" fly me to the moon "Вывод
4Ввод
"luffy is still joyboy"Вывод
6Нужно реализовать
def length_of_last_word(s: str) -> int:
Теги
strings
Prijavi se da vidiš povijest predaja
PrijavaPrijavi se da koristiš AI mentora
PrijavaVisible tests
1
Input
"Hello World"Expected
52
Input
" fly me to the moon "Expected
43
Input
"luffy is still joyboy"Expected
64
Input
"a"Expected
15
Input
" "Expected
06
Input
"HELLO WORLD"Expected
5Focus radio
Paused · SomaFM · Fluid