def checklimits(angle, maxleft, maxright):
    """
    :param angle:
    :param maxleft:
    :param maxright:
    :return:

    >>> checklimits(50, -45, 30)
    30
    >>> checklimits(-50, -45, 30)
    -45
    >>> checklimits(-20, -45, 30)
    -20
    """

    angle = max(angle, maxleft)
    angle = min(angle, maxright)
    return angle