[EMAIL PROTECTED] wrote:

> I'm playing around with list comprehension, and I'm trying to find the
> most aesthetic way to do the following:
> 
> I have two lists:
> 
> noShowList = ['one', 'two', 'three']
> 
> myList = ['item one', 'item four', 'three item']
> 
> I want to show all the items from 'myList' that do not contain any of
> the strings in 'noShowList'.

>>> no_show_list = ["one", "two", "three"]
>>> my_list = ["item one", "item four", "three item"]
>>> [item for item in my_list if not any(x in item for x in no_show_list)]
['item four']

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

Reply via email to