0 out of 68 challenges solved

Flatten a tree

**Question:**
Write a function called flatten that takes a tree structure as input and returns a flattened list of all the elements in the tree. The tree structure is represented as nested lists, where each list can contain either numbers or nested lists.

**Example:**
Input: flatten([1, [2, [3, 4], 5], 6])
Output: [1, 2, 3, 4, 5, 6]
def flatten(tree):
    """
    Returns a flattened list of all the elements in the tree.

    Args:
    tree: The input tree structure.

    Returns:
    list: The flattened list of elements.
    """
    # TODO: Implement the flatten function
    pass