def charLimit(min: int, max: int, char, string):
    """Ensure that the count of occurrences of char in string lies between min and max"""

    if max < min:
        raise(ValueError('max less than min.'))

    total = string.count(char)
    return total <= max and total >= min