def clip(min_bound, max_bound, value):
    """Limits the range value may take.

    Arguments:
        min_bound: the lowest allowed value of value.
        max_bound: the highest allowed value of value.
        value: a whose value should be limited to being between min_bound
        and max_bound.
    Return:
        if value < min_bound, min_bound; if value > max_bound, max_bound;
        otherwise, value.
    """
    return max(min_bound, min(value, max_bound))