I want to know whether there is an equivalent statement in lists to do the following. In MATLAB I would do the following
fid = fopen(\'inc.txt\',\'w\')
init
I think that the original poster wanted 51 to show up in the list, as well.
The Python syntax for this is a little awkward, because you need to provide for range (or xrange or arange) an upper-limit argument that is one increment beyond your actual desired upper limit. An easy solution is the following:
init = 1
final = 51
inc = 5
with open('inc.txt','w') as myfile:
for nn in xrange(init, final+inc, inc):
myfile.write('%d\n'%nn)