here is my code
old_lists = [['one', 'two', ['three', 'four', 'five']], ['six', 'seven', ['eight', 'nine', 'ten']], ['eleven', 'twelve', ['thirteen', 'fourteen', 'fifteen']]] new_list = [] for i, j, k in old_lists: new_list.append(i, j, k) print(new_list)
I am getting this output
one two ['three', 'four', 'five'] six seven ['eight', 'nine', 'ten'] eleven twelve ['thirteen', 'fourteen', 'fifteen']
I would like the below output
['one', 'two', 'three', 'four', 'five'] ['six', 'seven', 'eight', 'nine', 'ten'] ['eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen']
Advertisement
Answer
new_list = [] for i, j, k in old_lists: new_list.append( [i,j]+k ) print(new_list)
Or even better:
new_list = [ [i,j]+k for i,j,k in old_lists ]