1.遞歸實現app
a = [1,[2,[3],4],5] def list_more(arg): new_list = [] for i in arg: if type(i) is not list: new_list.append(i) else: new_list.extend(list_more(i)) return new_list In [65]: list_more(a) Out[65]: [1, 2, 3, 4, 5]