
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Index minimum value Record in Python
If it is required to find the tuple corresponding to the minimum value of other tuple index, it can be done using the 'min' method, and the 'operator.itemgetter' method.
The 'min' method gives the minimum of the elements in the iterable. The itemgetter fetches a specific item from its operand.
Below is a demonstration of the same −
Example
from operator import itemgetter my_list = [('Will', 45), ('Jam', 13), ('Pow', 89), ('Nyk', 56)] print ("The list is: " ) print(my_list) my_result = min(my_list, key = itemgetter(1))[0] print ("The value with minimum score is : " ) print(my_result)
Output
The list is: [('Will', 45), ('Jam', 13), ('Pow', 89), ('Nyk', 56)] The value with minimum score is : Jam
Explanation
- The required packages are imported.
- A list of tuples is defined, and is displayed on the console.
- The 'min' function is applied on this list of tuples, with the key as the itemgetter.
- This itemgetter helps fetch a specific item from the operand.
- This value is assigned to a variable.
- This variable is the output, which is displayed on the console.
- Related Articles
- Python - Return the minimum value of the Pandas Index
- Python – Index Value repetition in List
- Maximum value in record list as tuple attribute in Python
- Dictionary with index as value in Python
- Path With Maximum Minimum Value in Python
- Find minimum of each index in list of lists in Python
- Python – Replace value by Kth index value in Dictionary List
- Accessing index and value in a Python list
- How to select record except the lower value record against a specific value in MySQL?
- Program to find number of minimum steps to reach last index in Python
- Python – Convert List to Index and Value dictionary
- How to find the index of the minimum and maximum value of a vector in R?
- Minimum Index Sum of Two Lists in C++
- Delete a record with tablename.columnname= value in MySQL
- Python – Sort Dictionary List by Key’s ith Index value

Advertisements