generate functionTue, 23 May 2023
given a set of integers and a value for which you need to find the nearest one.
def find_nearest(array, value): idx = np.abs(np.asarray(array)-value).argmin() return array[idx] find_nearest([10,12,18,20],15)
Python
Generate More