[Tutor] different results: why?

Isr Gish isrgish at fusemail.com
Thu Jan 15 20:27:25 EST 2004



"ali"<rmangaliag at slu.edu.ph> wrote:

"tutor at python.org"<tutor at python.org>
   >Subject: [Tutor] different results: why?
   >
   >
   >why are the results of these codes different?
   >
   >###### 1 ######
   >
   >if True==[1,2,3]:
   >    print "test"
   >
   >###### 2 ######
   >
   >if [1,2,3]:
   >    print "test"
   >
True is only equal to 1, nothing else.

But [1,2,3] is True, because every none empty list evaluates to True.
Thefore if [1,2,3]: evaluates to to True so it prints "test".

Isr





More information about the Tutor mailing list