For this Question: Given a string s consisting of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.

If the last word does not exist, return 0.

Note: A word is defined as a character sequence consists of non-space characters only.Input contains a single line string.

Constraints:

1 <= |String length| <= 100000Output the length of the last word.Sampe input 1
Hello World

Sample output 1
5


Explanation
Given s = "Hello World",

return 5 as length("World") = 5.

Please make sure you try to solve this problem without using library functions. Make sure you only traverse the string once., I have written this Solution Code: def length_of_last_word(s):
        words = s.split()
        if len(words) == 0:
            return 0
        return len(words[-1])

a = input()
print(length_of_last_word(a)), In this Programming Language: Python, Now tell me if this Code is compilable or not?