Hello fellas,
I'm stuck with the flatten list exercise.. this is the code i wrote:
def flat_list(array):
ult_list = []
for items in array:
if type(items) == type(array):
for item in items:
if type(item) == type(array):
for another_one in item:
if type(another_one) == type(array):
for other in another_one:
ult_list.append(other)
else:
ult_list.append(another_one)
else :
ult_list.append(item)
else :
ult_list.append(items)
print(ult_list)
return ult_list
I knew it was wrong from beginning because it has a max number of iterations (it is limited), so i just tried to do all good until it worked and then see the best solutions for this but it actually requires more loops when you check.
But I'm a newby and i dont even know how to loop in a element from a list to see if the element inside is still a list and same again...
Can you light my way a little? I need some clues to finish this one.
Thanks ppl
From: https://py.checkio.org/mission/flatten-list/solve/
Created at: 2019/07/21 17:42; Updated at: 2019/07/21 18:15