James Stroud wrote:
Hello,

I am looking for a nice way to take only those charachters from a string that are in another string and make a new string:


astr = "Bob Carol Ted Alice"
letters = "adB"
some_func(astr,letters)

"Bad"

astr = "Bob Carol Ted Alice" letters = "adB" both = [x for x in astr if x in letters] print both

>>>
['B', 'a', 'd']
>>>
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to