Example:
tuple = ("python", "includehelp", 43, 54.23)
Index Minimum Values Record
The problem consists of a list of tuples where each tuple consists of two values, one an index which is a string, and another an integer value. We will be creating a python program to find the index of minimum value record.
Input:
[('python', 51), ('Scala', 98), ('C/C++', 23)]
Output:
'C/C++'
To find the solution, we will iterate over the list and find the record with minimum value and print its index.
In Python, we can perform the task in multiple ways using one of the multiple methods that are present in the function.
Method 1:
One method to solve the problem is by using the itemgetter() method to get the index of each tuple and find the minimum value using the min() method and return its index.
Output:
Method 2:
Another method to solve the problem is by using lambda function instead of itemgetter to extract the record's value and then return the index of the minimum value record.
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer