<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert(self, names, src=None, to='ISO3', enforce_list=False, not_found='not found', exclude_prefix=['excl\\w.*', 'without', 'w/o']):
 """ Convert names from a list to another list. Note ---- A lot of the functionality can also be done directly in Pandas DataFrames. For example: coco = CountryConverter() names = ['USA', 'SWZ', 'PRI'] coco.data[coco.data['ISO3'].isin(names)][['ISO2', 'continent']] Parameters names : str or list like Countries in 'src' classification to convert to 'to' classification src : str, optional Source classification. If None (default), each passed name is checked if it is a number (assuming UNnumeric) or 2 (ISO2) or 3 (ISO3) characters long; for longer names 'regex' is assumed. to : str, optional Output classification (valid index of the country_data file), default: ISO3 enforce_list : boolean, optional If True, enforces the output to be list (if only one name was passed) or to be a list of lists (if multiple names were passed). If False (default), the output will be a string (if only one name was passed) or a list of str and/or lists (str if a one to one matching, list otherwise). not_found : str, optional Fill in value for none found entries. If None, keep the input value (default: 'not found') exclude_prefix : list of valid regex strings List of indicators which negate the subsequent country/region. These prefixes and everything following will not be converted. E.g. 'Asia excluding China' becomes 'Asia' and 'China excluding Hong Kong' becomes 'China' prior to conversion Default: ['excl\\w.*', 'without', 'w/o']) Returns ------- list or str, depending on enforce_list """

        # The list to tuple conversion is necessary for Matlab interface
        names = list(names) if (
                isinstance(names, tuple) or
                isinstance(names, set)) else names

        names = names if isinstance(names, list) else [names]

        names = [str(n) for n in names]

        outlist = names.copy()

        to = [self._validate_input_para(to, self.data.columns)]

        exclude_split = {name: self._separate_exclude_cases(name,
                                                            exclude_prefix)
                         for name in names}

        for ind_names, current_name in enumerate(names):
            spec_name = exclude_split[current_name]['clean_name']

            if src is None:
                src_format = self._get_input_format_from_name(spec_name)
            else:
                src_format = self._validate_input_para(src, self.data.columns)

            if src_format.lower() == 'regex':
                result_list = []
                for ind_regex, ccregex in enumerate(self.regexes):
                    if ccregex.search(spec_name):
                        result_list.append(
                            self.data.ix[ind_regex, to].values[0])
                    if len(result_list) > 1:
                        logging.warning('More then one regular expression '
                                        'match for {}'.format(spec_name))

            else:
                _match_col = self.data[src_format].astype(
                    str).str.replace('\\..*', '')

                result_list = [etr[0] for etr in
                               self.data[_match_col.str.contains(
                                    '^' + spec_name + '$', flags=re.IGNORECASE,
                                    na=False)][to].values]

            if len(result_list) == 0:
                logging.warning(
                    '{} not found in {}'.format(spec_name, src_format))
                _fillin = not_found or spec_name
                outlist[ind_names] = [_fillin] if enforce_list else _fillin
            else:
                outlist[ind_names] = []
                for etr in result_list:
                    try:
                        conv_etr = int(etr)
                    except ValueError:
                        conv_etr = etr
                    outlist[ind_names].append(conv_etr)

                if len(outlist[ind_names]) == 1 and enforce_list is False:
                    outlist[ind_names] = outlist[ind_names][0]

        if (len(outlist) == 1) and not enforce_list:
            return outlist[0]
        else:
            return outlist