Sobes.tech
Intern — Middle

Converting a nested list to a homogeneous form

livecode

Task condition

It is necessary to implement a function that takes a list, which may contain other lists of any depth, and returns a new list where all elements are on the same level.

nested_list = [[1, 2, [3, [4, [5]]]], 6, 7, 8]

The function should recursively "flatten" any nested arrays, preserving the order of elements.