Ada :
How do I concatenate two lists inside the nested list Python?
I have this list
lists_of_lists =[[[1],[2]],[[3],[5]],[[6],[6]]]
And my expected output is
lists_of_lists =[[1,2],[3,5],[6,6]]
I tried this way
new = []
lists_of_lists =[[[1],[2]],[[3],[5]],[[6],[6]]]
for i in range(len(lists_of_lists)):
for list in lists_of_lists[i]:
for element in list:
new.append(element)
print(new)
But I got
[1, 2, 3, 5, 6, 6]
Thank you for any suggestions
r.ook :
[[i for inner in sub_lists for i in inner] for sub_lists in lists_of_lists]
# [[1, 2], [3, 5], [6, 6]]