On 15 January 2013 23:53, Scurvy Scott <etanes...@gmail.com> wrote:
>> > Anyways, the problem I'm having is I'm not really sure how to search a list
>> > for multiple elements and remove just those elements. Below is my code so
>> > far, and information y'all could provide would be appreciated. Thanks.
>>
[SNIP]
>
> What I meant to say is, I want to be able to search the generated list
> for a specific set of strings so like
>
> list = ['a','b','c','d','e','f','g']
> search = ['b','d','g']
> list.del[search]

How about:

new_list = [element for element in list if element not in search]

(It would be more efficient to use a set but it's not strictly necessary)


Oscar
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to