You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
def length_of_last_word(s):
|
|
words = s.split()
|
|
if len(words) == 0:
|
|
return 0
|
|
return len(words[-1])
|
|
|
|
print(length_of_last_word("Python Exercises"))
|
|
print(length_of_last_word("Python"))
|
|
print(length_of_last_word(""))
|
|
print(length_of_last_word(" ")) |