Python Practice › List Programs › Program 30
Second smallest number
Write a Python program to find the second smallest number in a list.
Input
[10, 4, 32, 4, 18]
Output
10
Approach
- Sort the unique values and take index 1.
Solution
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.