Trying to unnest this list: [1, [2, 3, [4, 5, [6]]], [7, 8], 9]
Into this list: [1, 2, 3, 4, 5, 6, 7, 8, 9]
So far this is my function:
L = [1, [2, 3, [4, 5, [6]]], [7, 8], 9]
def unnesting(L):
     my_list = []
     for element in (L):
    
         if type(element) is list:             
             my_list.extend(element)
        
         else:
             my_list.append(element)
   
return my_list
except it gives me this output: [1, 2, 3, [4, 5, [6]], 7, 8, 9]
Any solutions or advice on how to unnest this list? Thank you!
 
     
     
     
     
    