Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to merge a list of list of list as one? without wasting too much if your time.
The question is published on by Tutorial Guruji team.
The question is published on by Tutorial Guruji team.
If I have 2 liist of list of list:
A = [ [[2,3],[3,4]] ] B = [ [[5,6],[7,3],[3,1]], [[2,5],[3,2],[4,2]], [[2,1],[2,3],[3,1]] ]
and I want to merge A into B.So the first list of list of A is in the first list of list of B and so on.
Output:
C = [ [[5,6],[7,3],[3,1],[2,3],[3,4]], [[2,5],[3,2],[4,2]], [[2,1],[2,3],[3,1]] ]
I tried using zip(A,B) but they are put in tuples and list so it’s really confusing?
Answer
This would work:
>>> A=[ [ [2,3],[3,4] ] ] >>> B=[ [ [ [5,6],[7,3],[3,1]],[ [2,5],[3,2],[4,2] ],[ [2,1],[2,3],[3,1]]]] >>> B[0][0] += A[0] >>> B [[[[5, 6], [7, 3], [3, 1], [2, 3], [3, 4]], [[2, 5], [3, 2], [4, 2]], [[2, 1], [2, 3], [3, 1]]]]
Edited answer.
We are here to answer your question about How to merge a list of list of list as one? - If you find the proper solution, please don't forgot to share this with your team members.