Consider the following MWE.
f_500 = open('halo_classificatio_500_with_surface_pressure_term.txt', 'a')
f_200 = open('halo_classificatio_200_with_surface_pressure_term.txt', 'a')
f_178 = open('halo_classificatio_178_with_surface_pressure_term.txt', 'a')
f_100 = open('halo_classificatio_100_with_surface_pressure_term.txt', 'a')
over_density = [500,200,178,100]
for jj in over_density:
tm_msun = 2
cm_msun = 2
vr_mpc = 2
file('f_'+str(jj)).write("%s\t%s\t%s\n" % (tm_msun, cm_msun, vr_mpc))
I am getting the following error
IOError: [Errno 2] No such file or directory: 'f_500'
I would like to write to file object f_500 when 'jj' is 500 and so on. What could be the correct way of doing this ?
Thanks