I'd like to iterate a python script over a set of data variables. I have input data variables named data_X
, data_Y
, etc. which are defined at the beginning of my script, e.g. data_X = [1, 2, 5, 42, 793]
. In bash, I could just use "$X" to specify that I want the string, so I'm looking for a python equivelent.
When I try
for variable in ['X', 'Y']:
run_data = 'data_' + variable
what happens is that run_data is now equal to a string data_X
, but not equal to the actual data that I had earlier defined as data_X
How do I specify that I want run_data
to equal the values originally assigned to data_X
?