Light Mode
Dark Mode
Nearest Value

I keep getting a Type Error when I run this code, however it appears to run normally in the online IDE I'm using. Thoughts?

def nearest_value(values: set, one: int) -> int:
    a = [abs(one - value) for value in values]
    index_min = a.index(min(a))
    if one in values:
        return one
    else:
        return values[index_min]
Created: Oct. 20, 2021, 9:23 a.m.
Updated: Oct. 20, 2021, 11:57 a.m.
0
5
User avatar
ryan.obar