from typing import Union


def clamp(value: Union[float, int], lower: Union[float, int], upper: Union[float, int]) -> Union[float, int]:
    """
    Clamp a number
    Same as min(max((value, lower), higher)

    Args:
        value (Union[float, int]): Value to clamp
        lower (Union[float, int]): min value
        upper (Union[float, int]): max value

    Returns:
        Union[float, int]: clamped value
    """
    return lower if value < lower else upper if value > upper else value