9 lines
259 B
Python
9 lines
259 B
Python
|
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]))
|