Untitled

 avatar
unknown
plain_text
a year ago
370 B
6
Indexable
def sum_nested_lists(nested_list):
    total = 0
    for element in nested_list:
        if isinstance(element, list):
            total += sum_nested_lists(element)
        else:
            total += element
    return total

# Example usage:
nested_list = [[1, 2, 3], [4, 5], [6, [7, 8], 9]]
result = sum_nested_lists(nested_list)
print("Sum of nested lists:", result)
Editor is loading...
Leave a Comment