I have such a list:
mylist=[[[1,2,3,...,200],[1,2,3,...,200],[1,2,3,...,200],[1,2,3,...,40]],...]
I want to merge the first three lists in each item in mylist and have something like this:
final_list=[[[1,2,3,...,600],[1,2,3,...,40]],...]
I have written this code to do that:
def extend(mylist):
a=mylist[0]
b=mylist[1]
c=mylist[2]
a.extend(b)
a.extend(c)
return a
final_list=[]
for i in mylist:
final_list.append([extend(i),i[3]])
it works properly when the lists are small, but when I want to merge three 200-array lists into a 600-array list, I face "MemorryError":
a.extend(c)
MemoryError
How can this problem be solved?