On 4/19/05, James Stroud <[EMAIL PROTECTED]> wrote:

> astr = "Bob Carol Ted Alice"
> letters = "adB"
> 
> import sets
> alist = [lttr for lttr in astr if lttr in Set(letters)]
> newstr = ""
> for lttr in alist:
>   newstr += lttr

>>> astr = "Bob Carol Ted Alice"
>>> letters = "adB"
>>> s1 = set(astr)   # set is a core data type in Py2.4
>>> s2 = set(letters)
>>> ''.join(s1 & s2)
'aBd'

>>> .    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to