Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python get nearest value in list

def takeClosest(num,collection):
   return min(collection,key=lambda x:abs(x-num))
 
PREVIOUS NEXT
Tagged: #python #nearest #list
ADD COMMENT
Topic
Name
8+6 =