Python: find closest value in list of lists

Print d does not work. Is there a possibility it can work?

aFind=1
a=[0,1,2,3,4]
b=min(a,key=lambda x:abs(x-aFind))
print (b)

cFind=[1,1,1]
c=[[0,0,4],[1,1,1],[2,2,3],[3,3.0]]
d=min(c,key=lambda c:(abs(c[2]-cFind[2]),abs(c[1]-cFind[1]),abs(c[0]-cFind[0])))
print (d)

I do not see myself dancing on this music, I try to avoid it.

has a typo with a point iso a comma

-Willem

1 Like

Willem is an amazing name.

1 Like