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 nearest(given_list, num): return min(given_list, key=lambda x:abs(x-num)) nearest([1,2,3,4,5], 5)

Want to kickstart your project?Use the new AI Studio to create your code