<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def alphanum_variable(min_size, max_size, name=None):
 """ Creates the grammar for an alphanumeric code where the size ranges between two values. :param min_size: minimum size :param max_size: maximum size :param name: name for the field :return: grammar for an alphanumeric field of a variable size """


    if name is None:
        name = 'Alphanumeric Field'

    if min_size < 0:
        # Can't have negative min
        raise BaseException()
    if max_size < min_size:
        # Max can't be lower than min
        raise BaseException()

    field = pp.Word(pp.alphanums, min=min_size, max=max_size)

    # Parse action
    field.setParseAction(lambda s: s[0].strip())

    # White spaces are not removed
    field.leaveWhitespace()

    # Name
    field.setName(name)

    return field