<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def add_index(self, values, name=None):
        'add an index of ``name`` with the list of ``values``'
        if len(values) != len(set(values)):
            raise ValueError('Values in the new index are not unique')

        d = self.indices
        if len(values) != len(self) and len(values) and d:
            raise ValueError('Length of values in added index (%s) does not match '
                             'length of existing items (%s)' % (len(values), len(self)))

        if name is None:
            name = 'index_' + str(len(d)+1)
            name = get_unique_name(name, d)
        else:
            MI_check_index_name(name)
            if name in d:
                raise ValueError('Duplicate index name: %s' % (name,))

        if len(d) == 0:
            items = [(v,) for v in values]
        else:
            items = [i+(v,) for i, v in zip(self.items(), values)]

        names = force_list(d.keys()) + [name]

        self.clear(True)
        _MI_init(self, items, names)