Python Program to Find Smallest Number in a List (original) (raw)

Last Updated : 28 Oct, 2025

Given a list of numbers, the task is to find the smallest element in that list.

**For example:

li= [8, 3, 1, 9, 5] -> Smallest number = 1
li = [10, 25, 7, 30, 2] -> Smallest number = 2

Let’s explore different methods to find smallest number in a list.

Using min()

min() function takes an iterable (like a list, tuple etc.) and returns the smallest value.

Python `

a = [8, 3, 5, 1, 9, 12] res = min(a) print(res)

`

Using for Loop

We can also find the smallest number in a list using a loop (for loop). This method is useful for understanding how the comparison process works step by step.

Python `

a = [8, 3, 5, 1, 9, 12] res = a[0] for val in a: if val < res: res = val

print(res)

`

**Explanation:

Using Sorting

Another way to find the smallest number in a list is by sorting it. Once sorted in ascending order, the smallest number will be at the beginning of the list.

Python `

a = [8, 3, 5, 1, 9, 12] a.sort() res = a[0] print(res)

`

**Explanation: