# Python | Program to find the position of minimum and maximum elements of a list

Here, we are going to learn how to **find and print the position/index of minimum and maximum elements of a list**? To find the minimum and maximum elements, we use **min() and max() methods in Python**.

Submitted by **IncludeHelp**, on July 25, 2018

**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**

# declare a list of Integers list = [10, 1, 2, 20, 3, 20] # min element's position/index min = list.index (min(list)) # max element's position/index max = list.index (max(list)) # printing the position/index of min and max elements print "position of minimum element: ", min print "position of maximum element: ", max

**Output**

position of minimum element: 1 position of maximum element: 3

**Explanation:**

- The minimum number of the list is 1 and it is at 1
^{st}position in the list. To get it’s index, we use list.index(min(list)) statement, min(list) returns 1 (as minimum element) and list.index(1) returns the index of 1 from the list. Hence, the position of minimum element is: 1 - The maximum number of the list if 20 and it is two times in the list, first occurrence of 20 is at 3
^{rd}position and the second occurrence of 20 is at 5^{th}position. Statement max(list) returns the maximum element of the list, which is 20 and the statement list.index(20) returns the index/position of first matched element. Hence, the position of maximum element is: 3

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions

**Ad:**
Are you a blogger? Join our Blogging forum.

Learn PCB Designing: PCB DESIGNING TUTORIAL