<float>range(0.0,100.0,0.1)

Michael Hudson mwh21 at cam.ac.uk
Wed May 17 16:06:06 EDT 2000


"Warren Postma" <embed at geocities.com> writes:

> how do you do this:
> 
> for i in range(0.0, 100.0, 0.1):
>     print i
> 
> range doesn't like a non-integer step and won't produce a list of floats
> instead of integers.

for i in map(lambda x:x/10,range(1000)):
    print i

?  This is probably the best solution wrt roundoff; beware of
repeatedly adding 0.1 to floats...

Cheers,
M.

-- 
  I saw `cout' being shifted "Hello world" times to the left and
  stopped right there.
                                                    -- Steve Gonedes



More information about the Python-list mailing list