def flatten_list(alist:list) -> list: out = [] for l in alist: if not isinstance(l, list): out.append(l) else: out.extend(flatten_list(l)) return out