Python Practice › List Programs › Program 30

Second smallest number

EasyList Programs · 30 of 100

Write a Python program to find the second smallest number in a list.

Advertisement
Input
[10, 4, 32, 4, 18]
Output
10

Approach

  1. Sort the unique values and take index 1.

Solution

Python
numbers = [10, 4, 32, 4, 18]print(sorted(set(numbers))[1])
Output
10

Learn the concept

New to this topic? Read the lesson, then come back.

More list programs

← All 100 List Programs

Leave a Comment