{"id":14307,"date":"2021-09-30T12:30:02","date_gmt":"2021-09-30T07:00:02","guid":{"rendered":"https:\/\/python-programs.com\/?p=14307"},"modified":"2021-11-22T18:34:38","modified_gmt":"2021-11-22T13:04:38","slug":"python-program-to-print-nth-word-in-a-given-string","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-print-nth-word-in-a-given-string\/","title":{"rendered":"Python Program to Print Nth word in a given String"},"content":{"rendered":"

In this article, we will look at how to find the Nth word in a given text using Python.
\nWe frequently encounter circumstances in which we do not require the complete string but merely a certain word from it.<\/p>\n

Given multiple strings separated by spaces, the task is to print the Nth word in the given string in Python.<\/p>\n

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

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

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

Given string =Good morning this is btechgeeks platform\r\nGiven n=3<\/pre>\n

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

The [ 3 ] th word in the given Good morning this is btechgeeks platform is { this }<\/pre>\n

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

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

Given string =hello thi sis btechgeeks\r\nGiven n=4<\/pre>\n

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

The [ 4 ] th word in the given hello thi sis btechgeeks is { btechgeeks }<\/pre>\n

Program to Print Nth word in a given String in Python<\/h2>\n

Below are the ways to print the Nth word in the given string in Python.<\/p>\n