Say I have a bunch of lists, let's call them x and y. They're coming from some data files, and those data files are numbered, say 1-36. Is there a way for me to go through each data file, and assign the number to x_1,y_1,x_2,y_2 as the variables?
For example:
def read_data(location):
kx_input = []
ky_input = []
with open(location) as f:
for line in f:
cols = line.split()
kx_input.append(float(cols[0]))
ky_input.append(float(cols[1]))
return kx_input,ky_input
for i in range(1,36):
x,y = read_data('file_'+str(i)+'_data')
Except this redefines x and y each time, I want it to create an x_i,y_i with i being the value of i during each iteration. So in the end I would have x_1,y_1....x_36,y_36 as a bunch of lists.
To deal with this issue before I've made classes and appended all the x's and y's together and had a separate value that assigned them to a number, but I'm just wondering if it's possible to do it another way.