# [Tutor] creating a tab delimited filename

C Smith smichr at hotmail.com
Thu Mar 17 06:45:40 CET 2005

```Hi Jacob,

###
if i==1000:
i=0
else:
i=i+1
###

Since this test is done after you have stored your data you are
actually going to store 1001 pieces of data.
i starts at 0
you store 0
you do your test and i is incremented
{that's set 1}
i is 1
you store 1
you do your test and i is incremented
{that's set 2}
...
i is 1000
you store 1000
you do your test and i is set to 0
{that's set 10001}

Also, it looks like you have that i-incrementing happening at the same
level as the if-test. If so, it is possible that the i's that are used
to store the data will not increase by 1 each time since they are being
incremented for every k and not only when the data is being stored. If
you only want it incremented when something is stored, put it inside
the if-block.  Also, consider using the modulo operator to keep track
of i: replace your test with

###
i = (i+1)%1000
###

i starts and 0 and will be incremented until it is 999 and then when
this calculation is then performed you will calculate (999+1)%1000
which is 1000%1000 which is 0--just what you wanted.  Here's an example
that cycles through 3 number, 0, 1, and 2:

###
>>> j=0
>>> for i in range(10):
..   print j
..   j = (j+1)%3
..
0
1
2
0
1
2
0
1
2
0
###

/c

```