def get_nearest_less_element(d, k):
return (min(value for value in map(float, d.values()) if value >= k))
So, d is a dict() and k is float, this function returns me the correct value, but can I return the corresponding key of that value from this function?
def get_nearest_less_element(d, k):
return min(key for key, value in d.items() if float(value) >= k)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With