[Tutor] results: why different?

Gonçalo Rodrigues op73418 at mail.telepac.pt
Thu Jan 15 07:04:09 EST 2004


Em Thu, 15 Jan 2004 18:07:03 +0800, "ali" <rmangaliag at slu.edu.ph>
atirou este peixe aos pinguins:

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

Let me give you an hint: replace [1, 2, 3] by some other object and do
the same experiment. For example, let us try with "some string"

>>> if True == "some string":
... 	print "Test"
... 	
>>> if "some string":
... 	print "Test"
... 	
Test
>>> 

The same thing happens.

Can you see why?

I'll get back to you,
G. Rodrigues



More information about the Tutor mailing list