Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get second min no from array in python

import heapq
def second_smallest(numbers):
    return heapq.nsmallest(2, numbers)[-1]

second_smallest([1, 2, 3, 4])
# Output: 2
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #min #array #python
ADD COMMENT
Topic
Name
4+6 =