def flatten_list(unflattened_list):
    """Flatten list possibly containing lists within elements.

    Args:
        unflattened_list (list): The list to be flattened.

    Returns:
        (list): The flattened list.
    """
    flattened_list = []
    for li in unflattened_list:
        if isinstance(li, list):
            flattened_list.extend(flatten_list(li))
        else:
            flattened_list.append(li)

    return flattened_list