Length Of Last Word in a String | Python3 program for implementation of efficient approach to find length of last word ; Split by space and converting String to list and ; Driver code
def length ( str ) : NEW_LINE INDENT lis = list ( str . split ( " ▁ " ) ) NEW_LINE return len ( lis [ - 1 ] ) NEW_LINE DEDENT str = " Geeks ▁ for ▁ Geeks " NEW_LINE print ( " The ▁ length ▁ of ▁ last ▁ word ▁ is " , length ( str ) ) NEW_LINE