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

## Topic: Write a Python program to find the second smallest number in a list

Solution

def second_smallest(numbers): a1, a2 = float('inf'), float('inf') for x in numbers: if x <= a1: a1, a2 = x, a1 elif x < a2: a2 = x return a2 print(second_smallest([1, 2, -8, -2, 0]))

List all Python Programs