def clamp(n, minn, maxn):
    """
    Clamp the input value to be in [minn, maxn].

    Args:
        n (float or int): input value.
        minn (float or int): minimum value.
        maxn (float or int): maximum value.

    Returns:
        float or int: clamped value.
    """
    return max(min(maxn, n), minn)