Cody Bable

Generation

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(S, x): return min(S, key = lambda y: abs(y-x)) find_nearest([-1, 2, 4, 5, 6, 7, 9, 11], 6)

Questions about programming?Chat with your personal AI assistant