So I solved this with a solution I found online:
def flat*list(array):
if array == []:
return array
if isinstance(array[0], list):
return flat*list(array[0]) + flat*list(array[1:])
return array[:1] + flat*list(array[1:])

But I originally had the following code which from my research should have worked, yet it would only append integers and not recursively call the function on a nested list. What am I missing?

def flat_list(array):
flat = []
for a in array:
if type(a) is list:
flat_list(a)
else:
flat.append(a)
return flat

Created at: 2019/04/23 23:19; Updated at: 2019/04/24 11:49

The question is resolved.