[Tutor] the 'or' attribute

tpc at csua.berkeley.edu tpc at csua.berkeley.edu
Tue Dec 9 19:58:36 EST 2003


hi Cris, the Python 'or' operator returns y if x is false,
so:

w =3D x or y
print w

will yield x if x is true.  For Python truth value testing check out:

http://www.python.org/doc/current/lib/boolean.html#l2h-102

and for more on the 'or' operator:

http://www.python.org/doc/current/lib/boolean.html#l2h-102

I hope that helps you.

 On Tue, 9 Dec 2003, Leung Cris wrote:

> How do i use 'or' ? for e.g , i tried
>
>  x =3D 1 or 2
> print x
>
> it would always print 1, and never two. Why is that?
>
> _________________________________________________________________
> =A8=CF=A5=CE MSN Messenger=A1A=BBP=AAB=A4=CD=A6b=BDu=A4W=B2=E1=A4=D1: htt=
p://messenger.microsoft.com/tc
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>




More information about the Tutor mailing list