How to make a nested list to the one-dimensional without using modules? Example:
input : [[[2]], [4, [5, 6, [6], 6, 6, 6], 7]
output: [2, 4, 5, 6, 6, 6, 6, 6, 7]
I wrote function
result = []
def flat_list(array):
for x in array:
if isinstance(x, list):
flat_list(x)
else:
result.append(x)
print(x)
return result
I want to do it using only function and not using any variables outside. Thanks