Easy function, please help.

Paul Rudin paul.nospam at rudin.co.uk
Wed Feb 9 02:08:57 EST 2011

Nanderson <mandersonrandersonanderson at gmail.com> writes:

> loop would be infinite. I get what is happening in the function, and I
> understand why this would work, but for some reason it's confusing me
> as to how it is exiting the loop after a certain number of times. Help
> is appreciated, thanks.

It works because 0 tests false and because integer division yields
integers... eventually you'll get something like 1/10 giving 0.

It's not necessarily a good thing to rely on. For example if you try it
after "from __future__ import division" - or in python 3 - you'll get a
float as the result of the division and it won't test False.

More information about the Python-list mailing list