Write a Python function to find the length of the last word.


Topic: Write a Python function to find the length of the last word.

Solution

def length_of_last_word(s):
        words = s.split()
        if len(words) == 0:
            return 0
        return len(words[-1])



List all Python Programs