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
PostgreSQLv16

Ovdje će se prikazati rezultat izvršavanja koda

Visible tests
1
Input
"Hello World"
Expected5
2
Input
" fly me to the moon "
Expected4
3
Input
"luffy is still joyboy"
Expected6
4
Input
"a"
Expected1
5
Input
" "
Expected0
6
Input
"HELLO WORLD"
Expected5
Focus radio
Paused · SomaFM · Fluid