Is it possible to make a list with variables in it?
I'm making a quick simple harmonic oscillator program from an old Fortran prog to learn Python and I'd like to use a list to control output to a text file.
So far I have a list: writeLoop = [t, ' ', omega1, ' ', theta1, '\n']
...computation...
for i in writeLoop
textfile.write(str(i))
But all the output keeps on giving zeros as per the initial values of t, omega1 and theta1. It works when I output without using the list so the number crunching itself works well.
Is there an elegant way to use the current, newly calculated values of t, omega1, and theta1? Would there have to be some sort of pointer use? How would one program this in Python?
Thanks.
EDIT: I got it working by putting the list right before the for loop, but my original question still holds true for future reference.