[Tutor] trouble with function-- trying to check

Isaac hyperneato at gmail.com
Wed Mar 14 08:19:14 CET 2007


a, b, c are all in crab but d is not.


> >>> for c in 'abcd':
> ...    print (c == c in 'crab')
> ...
> True
> True
> True
> False



>
> Message: 5
> Date: Tue, 13 Mar 2007 13:01:48 -0700 (PDT)
> From: Terry Carroll <carroll at tjc.com>
> Subject: Re: [Tutor] trouble with function-- trying to check
>         differences btwn 2 strings
> To: tutor at python.org
> Message-ID:
>         <Pine.LNX.4.44.0703131257060.20277-100000 at violet.rahul.net>
> Content-Type: TEXT/PLAIN; charset=US-ASCII
>
> On Tue, 6 Mar 2007, Alan Gauld wrote:
>
> > But I've been up since 4:30am and am too tired to try
> > figuring it out just now, so maybe someone else will
> > explain! :-)
> >
> > >>> for c in 'abcd':
> > ...    print (c == c in 'crab')
> > ...
> > True
> > True
> > True
> > False
>
> Trying to understand that, I tried this, which left me even more
> confused:
>
> >>> 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/e7ffd4f7/attachment.htm 


More information about the Tutor mailing list