0
      lst = [1,2,3,4,[5,6], 7,8,9]
                new_lst = []
                for i in range(len(lst)):
                    if type(lst[i])==list:
                        new_lst.extend(lst[i])
                    else:
                        new_lst.append(lst[i])
                return new_lst
        and the new_lst = [1,2,3,4,5,6,7,8,9]

Is there a way to make this work for [1,2,[3,4,[5,6,[7]]],8,9,10] ? is it possible to get to work with list comprehension ?

0 Answers0