def constrain(value, lowest, highest):
    """Test whether `value` is within the range `(highest, lowest)`.
    Return `value` if it is inside the range, otherwise return
    `highest` if the value is *above* the range or `lowest` it the value
    is *below* the range.

    >>> constrain(-1, 2, 5)
    2
    >>> constrain(1, 2, 5)
    2
    >>> constrain(0, 2, 5)
    2
    >>> constrain(2, 2, 5)
    2
    >>> constrain(3, 2, 5)
    3
    >>> constrain(5, 2, 5)
    5
    >>> constrain(6, 2, 5)
    5
    >>> constrain(10, 2, 5)
    5

    """
    return min(highest, max(value, lowest))
