def constrain(amount, low, high):
    """Constrain the given value in the specified range.

    Examples ::

        >>> constrain(8, 1, 5)
        5

        >>> constrain(5, 1, 5)
        5

        >>> constrain(3, 1, 5)
        3

        >>> constrain(1, 1, 5)
        1

        >>> constrain(-3, 1, 5)
        1

    :param amount: The the value to be contrained.

    :param low: The lower constain.

    :param high: The upper constain.

    """
    if amount < low:
        return low
    elif amount > high:
        return high
    else:
        return amount
