def get_nearest(v, l):
    """
    Returns the index of the nearest value in a list
    """

    for i in range(len(l)):
        if l[i] < v:
            prev = l[i - 1]
            prevDiff = prev - v

            curr = l[i]
            currDiff = v - curr

            if prevDiff < currDiff:
                return i-1
            else:
                return i
    
    # If value larger than list values, return last list index
    return len(l) - 1