Source Code:
(back to article)
my_list = [3, 6, 1, 8, 4, 9] # To get the index of the maximum item max_index = max(enumerate(my_list), key=lambda x: x[1])[0] print(max_index) # Output: 5 # To get the index of the minimum item min_index = min(enumerate(my_list), key=lambda x: x[1])[0] print(min_index) # Output: 2
Result:
Report an issue