{"id":24580,"date":"2021-10-22T09:02:48","date_gmt":"2021-10-22T03:32:48","guid":{"rendered":"https:\/\/python-programs.com\/?p=24580"},"modified":"2021-11-05T19:43:06","modified_gmt":"2021-11-05T14:13:06","slug":"python-program-to-find-index-of-a-tuple-item","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-index-of-a-tuple-item\/","title":{"rendered":"Python Program to Find Index of a Tuple Item"},"content":{"rendered":"

In the previous article, we have discussed Python Program for memoryview() Function<\/a>
\nThe tuple index function in Python returns the index of a given tuple item. The index position of the first found value is returned by the tuple index function.<\/p>\n

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

TupleName.index(tupleValue, start, end)<\/pre>\n

If you specify a start value, the index function will begin searching from that point. Similarly, setting the end position causes the tuple index function to stop looking at that number.<\/p>\n

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

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

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

Given tuple = (10, 20, 30, 50, 70, 20)\r\nGiven first number = 50\r\nGiven second number = 20\r\nGiven start position = 2<\/pre>\n

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

The given number's 50 index position =  3\r\nThe given number's 20 index position after the given start position 2 =  5<\/pre>\n

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

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

Given tuple = (1, 3, 5, 7, 8, 2, 5)\r\nGiven first number = 3\r\nGiven second number = 5\r\nGiven start position = 3<\/pre>\n

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

The given number's 3 index position =  1\r\nThe given number's 5 index position after the given start position 3 =  6<\/pre>\n

Program to Find Index of a Tuple Item in Python<\/h2>\n