I have a number of lists called: index_1, index_2, index_3, ...., index_n.
What I want is to concatenate them all in a new list.
My code so far:
index_all=[]
for i in range(1,n+1):
index_all = index_all + globals()["index_"+str(i)]
However, I get an error:
KeyError: index_1
Any ideas as to how to solve this?
globals()["index_1"]via python consolelist_1tolist_n, but I don't see them in your code. Also it is not obvious whatindex_allrepresents. Why do you need any indices in a list, if you just want to concatenate the lists? Is that the list where you want to append all the contents of the other lists?globals()["list_"+str(i)]?