sets and subsets

Aahz aahz at pythoncraft.com
Wed Feb 11 17:18:12 EST 2004


[content at *bottom*]

In article <c0e890$6hu$1 at solaris.cc.vt.edu>,
Bart Nessux  <bart_nessux at hotmail.com> wrote:
>Works great too. Thanks to all for the info.
>
>Amy G wrote:
>> There you go... list comprehension.  That is definatly nicer to look at.
>> 
>> 
>> "Elaine Jackson" <elainejackson7355 at home.com> wrote in message
>> news:zcxWb.464065$JQ1.270296 at pd7tw1no...
>> 
>>>b=[x for x in b if x not in c]
>>>
>>>"Bart Nessux" <bart_nessux at hotmail.com> wrote in message
>>>news:c0e4g3$r1$1 at solaris.cc.vt.edu...
>>>| By using lists, I can create sets of number. Suppose I have three lists.
>>>| One list is the super-set, one is a set that contains all the numbers
>>>| (just like the super-set) and the last is sub-set of the super-set. For
>>>| example:
>>>|
>>>| a = [1,2,3,4,5] # The super-set.
>>>| b = [1,2,3,4,5] # Looks just like the super-set, but it's not.
>>>| c = [2,4] # A sub-set
>>>|
>>>| I'd like to remove 2 & 4 from set b BECAUSE they are present in set c...
>>>| this would make the sets look like this:
>>>|
>>>| a = [1,2,3,4,5]
>>>| b = [1,3,5]
>>>| c = [2,4]
>>>|
>>>| How do I test set c to find what it contains and then look at set b to
>>>| see if it contains any of those same numbers, and if so, remove them.
>>>|

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Argue for your limitations, and sure enough they're yours."  --Richard Bach



More information about the Python-list mailing list