- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to find the element from a Python list with a minimum value?

List is one of the most commonly used data structures provided by python. List is a data structure in python that is mutable and has an ordered sequence of elements. Following is a list of integer values −

## Example

Following is a list of integer values.

lis= [12,22,32,54,15] print(lis)

## Output

If you execute the above snippet, it produces the following output.

[12, 22, 32, 54, 15]

*In this article, we will look at different ways to find the minimum of the list in Python. For the above list, the minimum element of the list is 1.*

## Using the min() method

In this method, we use the **min()** method to find the minimum valued element. The **min()** method returns an element from the list with the minimum value.

### Example

The following is an example code for finding the minimum element of a list using the **min()** method.

list1 = [1, 0, 4, 5, 100] print("Smallest element of the list is:", min(list1))

### Output

If you execute the above snippet, it produces the following output.

Smallest element of the list is: 0

If you also want the indices and all the places where max element occurred, you can use the enumerate method. The enumerate method makes tuples of objects with indices at first index and objects at second.

### Example

Following is an example to find the indices of the element from a python list with minimum value −

my_list = [2, 3, 1, -4, -1, -4] m = min(my_list) print([i for i, j in enumerate(my_list) if j == m])

### Output

This will give the output −

[3, 5]

## Using the sort() method

Here we will find the minimum element of a list using the **sort()** method. The **sort()** method which is provided by python is used to sort the elements of the list in ascending or descending order. Default, it will sort in ascending order. After sorting the smallest element is at the first position of the list, so we print that element.

### Example

The following example code finds the smallest element of the list using **sort()** method.

list1 = [100, 1, 5, 80, 20] list1.sort() print("Smallest element of the list is:", list1[0])

### Output

If you execute the above snippet, it produces the following output.

Smallest element of the list is: 1

## Using for loop or without using the built in function.

In this method, we will not use built in functions rather we use a loop to find the smallest element in a list.

Here initially assume the first element as the minimum and then we iterate over a for loop where we compare with other elements in the list. While comparing with elements in the list we change the min variable if the element is lesser than the compared minimum element. Finally, after getting terminated from the loop we get the minimum element.

### Example

The following is an example code to get the minimum element from a list.

def MinElement(lst): min = lst[0] for ele in lst: if ele < min : min = ele return min lst = [100, 1, 5, 80, 20] print("Smallest element of the list is:", MinElement(lst))

### Output

If you execute the above snippet, it produces the following output.

Smallest element of the list is: 1

- Related Articles
- How to find the element from a Python list with a maximum value?
- Python program to find the maximum and minimum value node from a doubly linked list
- Python program to find the maximum and minimum value node from a circular linked list
- Get the minimum value from a list with multiple columns in MySQL?
- Write a Golang program to find the element with the minimum value in an array
- Python Program to print element with maximum vowels from a List
- How we can update a Python list element value?
- How to remove an element from a list in Python?
- How to find an element in a List with Java?
- Find minimum k records from tuple list in Python
- How to remove an element from a list by index in Python?
- Find the tuples containing the given element from a list of tuples in Python
- Program to Find Minimum Jumps Required to Reach a Value with Different Parity in Python
- Program to find local peak element indices from a list of numbers in Python
- How to pop the first element from a C# List?