[Tutor] trouble with function-- trying to check
Isaac
hyperneato at gmail.com
Wed Mar 14 08:43:41 CET 2007
a, b, c, or d is a type('str') not boolean which is what (c in "crab") is.
The [in] operator takes presedence, the first 3 times (c in "crab") returns
true and the last returns false; but the strings a, b, c, or d do not ==
true or false - therefore the test (c == (c in "crab")) always returns
false.
(I think)
cheers
-Isaac
reference:
http://docs.python.org/ref/summary.html
Terry wrote:
>>> for c in "abcd":
... print (c == c in "crab"), (c == (c in "crab"))
...
True False
True False
True False
False False
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070314/82f42cae/attachment.html
More information about the Tutor
mailing list