Cody Bable

Generation

generate functionTue, 23 May 2023

create a function of a set of integers and a value for which you need to find the nearest one.

def find_nearest_number(a, b): return min(a, key = lambda x:abs(x-b))

Questions about programming?Chat with your personal AI assistant