def flatten_list(nested_list): """ Flattens a nested list (list of lists) of arbitrary depth into a single, flat list. """ flat_list = [] for item in nested_list: if isinstance(item, list): # If the item is a list, extend the flat_list with its flattened version flat_list.extend(flatten_list(item)) else: # If the item is not a list, append it directly flat_list.append(item) return flat_list # Example Usage: nested = [1, [2, 3], [4, [5, 6, [7, 8]]], 9, [10]] flat = flatten_list(nested) print(f"Original nested list: {nested}") print(f"Flattened list: {flat}") another_nested = [1, 2, [3, [4, 5]], 6] print(f" Original nested list: {another_nested}") print(f"Flattened list: {flatten_list(another_nested)}")