I'm trying to condense some repetitive code by setting up a for loop to define variable names. I get that python doesn't like having operators on the left side of equations, but are there any workarounds for adding strings together for the sake of defining a variable name that will later be referenced?
cases = ['case1','case2', 'case3']
condition = ['con1', 'con2']
var = ['var1', 'var2', 'var3']
for i in cases :
for j in condition :
for k in var :
filename = i+j+k+'.txt'
i+j+k = np.loadtxt(filename)
plt.plot(x, i+j+k)
plt.show
I'm thinking my best option would option would be set up a matrix in the loop as
value[i,j,k] = np.loadtxt(filename)
plt.plot(x, value[i,j,k])
but that might lead to bigger headaches in the future so I'm trying to avoid if possible.