Hello,

Much to my disbelief, I realized I hadn't written a program in Python
as far as I can recall which required me to do something like this, in
psuedocode:

x = 0.1

for i = 0 to x step 0.01
# do something with i
end i

Simply stated, I want to start from say a value, 0 and go upto 0.1 in
increments of 0.01.  I don't want to create a list with the values
hard-coded and then iterate over it, and hence I would use a while
loop instead:

x = 0.1
while i < x:
   # do something with i
   i += 0.01

I think this is one case, where you definitely cannot do this with a
for loop assuming the following restrictions:

- Do not create a list of the floating point values as i=[0.01, 0.02,
0.03..] - either like that or by using a suitable mathematical formula
combined with a list comprehension
- Use numpy's linspace() to create the list for you


Thoughts?

Thanks,
Amit.

-- 
http://echorand.me
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to