[Tutor] Another assert() question
alan.gauld at btinternet.com
Sun Jul 13 09:50:17 CEST 2008
"Dick Moores" <rdm at rcblue.com> wrote
> But why will a tuple with two elements will always evaluate to
Thats the rule for evaluationg collections in Python.
An empty collection is False. Anything else is therefore true
if : -> false
if [1,2]: -> true
if (): -> false
if (1,2) - True
if "": -> False
if "foo": -> True
Does that help?
Author of the Learn to Program web site
More information about the Tutor