[Tutor] different results: why?

Alan Gauld alan.gauld at blueyonder.co.uk
Thu Jan 15 14:03:45 EST 2004


> why are the results of these codes different?
> 
> ###### 1 ######
> 
> if True==[1,2,3]:
>     print "test"
> 
> ###### 2 ######
> 
> if [1,2,3]:
>     print "test"

Coz a boolean value is not a list - they are not equal.
If you convert the list to a boolean (which happens 
implicitly in the second case) it works:

> if True==bool([1,2,3]):
>     print "test"


Alan G.



More information about the Tutor mailing list