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(values, target): values = sorted(values) index = bisect.bisect(values, target) return values[index-1:index+1]

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