[Tutor] trouble with function-- trying to check differences btwn 2 strings

Alan Gauld alan.gauld at btinternet.com
Tue Mar 6 18:03:11 CET 2007


"David Perlman" <dperlman at wisc.edu> wrote

> I can't figure out how this would ever work at all.  It seems like
> it's either checking to see whether boolean TRUE is in word2, or 
> else
> it's checking to see whether item is equal to boolean TRUE or FALSE,
> and neither of those should ever be true.

It's doing the latter and since anything that's not 'empty' in
Python evaluates to true we wind up checking whether
true == (item in word)

So if the item is in word we get true == true which is true.

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list