From 60c52b2aaa3f6b33dd6253f7662b7e2d46e5babf Mon Sep 17 00:00:00 2001 From: Luis Rodrigues Date: Thu, 13 Feb 2025 11:14:20 +0000 Subject: [PATCH] exercicio 58 resolvido com python --- 58-length_of_last_word/python/58.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 58-length_of_last_word/python/58.py diff --git a/58-length_of_last_word/python/58.py b/58-length_of_last_word/python/58.py new file mode 100644 index 0000000..deece98 --- /dev/null +++ b/58-length_of_last_word/python/58.py @@ -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])