<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_default(name=None, index=None):
 """ set the default configuration by name """

    default_was_set = False
    count = 1

    for configuration in _CONFIG.sections():
        if index != None:
            if count == index:
                _CONFIG.set(configuration, 'default', True)
                default_was_set = True
            else:
                _CONFIG.remove_option(configuration, 'default')

        if name != None:
            if configuration == name:
                _CONFIG.set(configuration, 'default', True)
                default_was_set = True
            else:
                _CONFIG.remove_option(configuration, 'default')

        count += 1

    if not default_was_set:
        raise JutException('Unable to find %s configuration' % name)

    with open(_CONFIG_FILEPATH, 'w') as configfile:
        _CONFIG.write(configfile)

    info('Configuration updated at %s' % _JUT_HOME)