def flatten_list(ls=[]):
flattened_list = []
def aux(ls):
for elem in ls:
if not isinstance(elem, list):
print("ADDING NO-LIST ELEMENT...")
flattened_list.append(elem)
else:
print("RECURSION...")
aux(elem)
aux(ls)
return flattened_list
print(flatten_list([[1,2,3,[4,5]],[6,7,8,9],10]))
ZGVmIGZsYXR0ZW5fbGlzdChscz1bXSk6CiAgICBmbGF0dGVuZWRfbGlzdCA9IFtdCiAgICAKICAgIGRlZiBhdXgobHMpOgogICAgICAgIGZvciBlbGVtIGluIGxzOgogICAgICAgICAgICBpZiBub3QgaXNpbnN0YW5jZShlbGVtLCBsaXN0KToKICAgICAgICAgICAgICAgIHByaW50KCJBRERJTkcgTk8tTElTVCBFTEVNRU5ULi4uIikKICAgICAgICAgICAgICAgIGZsYXR0ZW5lZF9saXN0LmFwcGVuZChlbGVtKQogICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgcHJpbnQoIlJFQ1VSU0lPTi4uLiIpCiAgICAgICAgICAgICAgICBhdXgoZWxlbSkKICAgIAogICAgYXV4KGxzKQogICAgCiAgICByZXR1cm4gZmxhdHRlbmVkX2xpc3QKICAgICAgICAgICAgCiAgICAgCiAgICAgICAKcHJpbnQoZmxhdHRlbl9saXN0KFtbMSwyLDMsWzQsNV1dLFs2LDcsOCw5XSwxMF0pKQ==
RECURSION...
ADDING NO-LIST ELEMENT...
ADDING NO-LIST ELEMENT...
ADDING NO-LIST ELEMENT...
RECURSION...
ADDING NO-LIST ELEMENT...
ADDING NO-LIST ELEMENT...
RECURSION...
ADDING NO-LIST ELEMENT...
ADDING NO-LIST ELEMENT...
ADDING NO-LIST ELEMENT...
ADDING NO-LIST ELEMENT...
ADDING NO-LIST ELEMENT...
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]