def flatten(data):
list1=[]
def flat(data):
nonlocal list1
if type(data)==list:
for i in data:
flat(i)
else:
list1.append(data)
print(list1)
This is my code.
I can't understand why the output of this function is always None
.
Besides, are there any method to renew the list at function?
my purpose: transform any list into flat-list.