deep_flatten(nested) that flattens a list which may contain other lists nested to any depth (not just one level) into a single flat list, preserving left-to-right order. Non-list elements should be kept as-is.nested = [1, [2, [3, 4], 5], [[6]], 7]
[1, 2, 3, 4, 5, 6, 7]
Every level of nesting is unwrapped recursively.
Recursion is natural here: if an element is itself a list, recurse into it; otherwise append it directly.