[Tutor] Loopy question
Mike Yuen
yuenm@cpsc.ucalgary.ca
Wed, 17 Jul 2002 22:07:19 -0600 (MDT)
This is a real newbie question.
I got a question about a step in a loop. I want to make my step really
small for a problem i'm testing. However, the interpreter says my step in
the for loop (0.01) is a zero step for range.
Now, I tried to make a variable a real and assign it a 0.01 value but it
didn't seem to work either.
Here's the exact error I get (hopefully you can provide a bit of insight):
Traceback (most recent call last):
File "2.py", line 6, in ?
for x in range(2, 5, 0.01):
ValueError: zero step for range()
for x in range(2, 5, 0.01):
for loop in range (1, 7, 2):
result = ((x-1)**loop) / (loop*((x+1)**loop))
sum = result + sum
answer = 2 * sum
print "X: ", x, " ", "Answer: ", answer
sum = 0
Thanks,
Mike