[Tutor] Loopy question
alan.gauld@bt.com
alan.gauld@bt.com
Fri, 19 Jul 2002 13:39:57 +0100
> I got a question about a step in a loop. I want to make my
> step really small for a problem i'm testing.
What you really mean is you want lots of steps?
> however, the interpreter says my step in the for loop(0.01)
> is a zero step for range.
Coz range uses integers not reals.
Solution? - you have to multiply up the values,
in your case by 1/0.01 = 100
so it becomes:
for i in range(200,500): # 300 steps
step = i/100.0 # 2.00, 2.01, 2.02,.., 4.99 etc
# use step here...
Alan G.