Implement an iterator that flattens arbitrarily nested lists in depth-first order.
Constraints
Example
>>> ni = NestedIterator([1, [2, [3, 4]], 5]) >>> list(ni) [1, 2, 3, 4, 5] >>> ni = NestedIterator([[1, 2], 3, [4, [5, [6]]]]) >>> iter(ni) is ni True >>> [next(ni) for _ in range(6)] [1, 2, 3, 4, 5, 6]
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints