Your question is Flatten Nested Lists in Python. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A Convex function may receive a list containing values and other lists. Write a function that flattens the structure into a single list while preserving the left-to-right order of every value.
Implement flatten_nested(values), where values is a list whose elements are either integers or nested lists with the same structure. Return a new list containing all integers in depth-first, left-to-right order. Empty lists contribute no values.
Do not mutate the input list. The nesting depth is valid for Python's recursion limit.
def flatten_nested(values):