I have n multi-lists. I want to merge them into one big multi-list.
Example:
listA = [[1,2],[3,4],[6,7]]
listB = [[10,20],[30,40],[60,70]]
output:
listAB = [[1,2,10,20],[3,4,30,40],[6,7,60,70]]
This is the code I wrote which computes the above:
listAB,tmp = [],[]
for i in range(len(listA)):
for j in range(len(listA[i])):
tmp.append(listA[i][j])
tmp.append(listB[i][j])
listAB.append(tmp)
tmp = []
This code only works when you have two list, and the sub-list have the same length. I want to merge multiple multi-lists which have different lengths of sub-lists. Is there some function in itertools which can do these?
For example:
listA = [[1,2,3],[3,4,5],[6,7,8]]
listB = [[10,20],[30,40],[60,70]]
listC = [[4,4],[5,5],[6]]
listABC = [[1,2,3,10,20,4,4],
[3,4,5,30,40,5,5],
[6,7,8,60,70,6]]