exercicio 58 resolvido com python

This commit is contained in:
2025-02-13 11:14:20 +00:00
parent 5e684fdf84
commit 60c52b2aaa

View File

@ -0,0 +1,10 @@
# 58. Length of Last Word
#
# Given a string s consisting of words and spaces, return the length of the
# last word in the string.
#
# A word is a maximal substring consisting of non-space characters only.
def lengthOfLastWord(s: str) -> int:
return len(s.strip().split(" ")[-1])