On 2008-03-21 05:16:41 PM, [EMAIL PROTECTED] wrote:
> alist = [] 
> blist = [ 'one','two','one and two','one and four','five','one two']
> for f in blist:
>       if 'one' and 'two' in f:
>               alist.append(f)
>    
> for i in alist:
>     print i
> 
> two
> one and two
> one two
> 
> 
> why is it printing the first "two"?

Look at the this line:

    if 'one' and 'two' in f:

You're basically saying:

    if ('one') and ('two' in f):

which is why you only get elements that contain 'two'.  

Ricky

Attachment: pgpLDeQ6Gg7ma.pgp
Description: PGP signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to