Loop with float increments (frange)?

Dan Sommers me at privacy.net
Fri Apr 14 10:24:51 EDT 2006


On 14 Apr 2006 06:11:38 -0700,
forum at anton.e4ward.com wrote:

> what's the standard way for a "for" loop with float increments?

Use a while loop instead:

    f = initial_value
    while f <= final_value:
        process(f)
        f = f + increment

Note that there is no general guarantee that f will actually be
final_value; see also <http://docs.python.org/tut/node16.html>.

Regards,
Dan

-- 
Dan Sommers
<http://www.tombstonezero.net/dan/>
"I wish people would die in alphabetical order." -- My wife, the genealogist



More information about the Python-list mailing list