{"id":15741,"date":"2021-08-12T09:37:33","date_gmt":"2021-08-12T04:07:33","guid":{"rendered":"https:\/\/python-programs.com\/?p=15741"},"modified":"2021-11-22T18:38:25","modified_gmt":"2021-11-22T13:08:25","slug":"python-program-to-get-the-last-word-from-a-string","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-get-the-last-word-from-a-string\/","title":{"rendered":"Python Program to get the Last Word from a String"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Subtract two Complex Numbers<\/a><\/p>\n

Given a string that contains the words the task is to print the last word in the given string in Python.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given string =hello this is BTechgeeks<\/pre>\n

Output:<\/strong><\/p>\n

The last word in the given string { hello this is BTechgeeks } is: BTechgeeks<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given string =good morning this is btechgeeks<\/pre>\n

Output:<\/strong><\/p>\n

The last word in the given string { good morning this is btechgeeks } is: btechgeeks<\/pre>\n

Program to get the Last Word from a String in Python<\/h2>\n

Below are the ways to get the last word from the given string in Python.<\/p>\n