Given a list and we have to find the index/position of minimum and maximum elements of a list in Python.
Prerequisite:
Example:
Input:
list = [10, 1, 2, 20, 3, 20]
Output:
Positive of minimum element: 1
Positive of maximum element: 3
Logic:
To find the positions/indexes of minimum and maximum elements of a list, we need to find the maximum and minimum elements of the list – to find the maximum element of the list, we will use max(list) and to find the minimum element of the list, we will use min(list).
And, to get their indexes, we will use list.index(max(list)) and list.index(min(list)).
Program to find the position of min and max elements of a list in Python
Output
Explanation: