True/false integer values

Peter Hansen peter at engcorp.com
Fri May 2 09:20:38 EDT 2003


Carsten Gehling wrote:
> 
> for i in range(1, 3):
>     print "The loop ran %d time%s" % (i, ('', 's')[i != 1])
> 
> The tuple ('', 's') has indexes 0 and 1. Does that mean, that the boolean
> "true" value in Python is 1 and not -1?

http://www.python.org/doc/current/ref/Booleans.html#l2h-292

-Peter




More information about the Python-list mailing list