find nearest element in list python code example
Example: python get nearest value in list
def takeClosest(num,collection):
return min(collection,key=lambda x:abs(x-num))
def takeClosest(num,collection):
return min(collection,key=lambda x:abs(x-num))