import copy


def _params_to_stringlist(params, prefix="   "):
    """ Convert a dictionary/list of parameters to a format string.

    Args:
        params: A dictionary/list of parameters.
        prefix: A string.

    Returns: A format string.

    Raises:
        ValueError: if unknown type of `params`.
    """
    param_list = []
    if isinstance(params, dict):
        for key, val in params.items():
            param_list.append(prefix + key + ": ")
            if isinstance(val, dict):
                param_list.extend(_params_to_stringlist(val, prefix + "   "))
            else:
                param_list[-1] += str(val)
    elif isinstance(params, list):
        prefix += "  "
        for item in params:
            for idx, (key, val) in enumerate(item.items()):
                if idx == 0:
                    newprefix = copy.deepcopy(prefix[:-2])
                    newprefix += "- "
                    param_list.append(newprefix + key + ": ")
                else:
                    param_list.append(prefix + key + ": ")
                if isinstance(val, dict):
                    param_list.extend(_params_to_stringlist(val, prefix + "   "))
                else:
                    param_list[-1] += str(val)
    else:
        raise ValueError("Unrecognized type of params: {}".format(str(params)))
    return param_list