def format_lmns(lmns):
    """ Checks if the format of the parameter lmns is correct, returning the
    appropriate format if not, and raise an error if nmodes=0.
    The required format for the ringdown approximants is a list of lmn modes
    as strings, with n the number of overtones desired. For instance,
    lmns = ['223','331'] are the modes 220, 221, 222, and 330.
    The ConfigParser of a workflow might convert that to a single string
    (case 1 below) or a list with a single string (case 2), and this function
    will return the appropriate list of strings. If a different format is
    given, raise an error.
    """
    if isinstance(lmns, str):
        lmns = lmns.strip('[]').split(',')
    elif len(lmns) == 1 and isinstance(lmns[0], str) and len(lmns[0]) > 3:
        lmns = lmns[0].split(',')
    out = []
    for lmn in lmns:
        lmn = str(int(lmn))
        if len(lmn) != 3:
            raise ValueError(
                'Format of parameter lmns not recognized. See approximant documentation for more info.'
                )
        elif int(lmn[2]) == 0:
            raise ValueError(
                'Number of overtones (nmodes) must be greater than zero in lmn={}.'
                .format(lmn))
        out.append(lmn)
    return out
