Newbie here... getting a count of repeated instances in a list.

Peter Otten __peter__ at web.de
Mon Nov 24 17:36:46 EST 2003


Amy G wrote:

> I now have two dictionaries, each with domains and frequncies.  I want to
> have the domains which appear in both to be deleted from the first one.
> 
> Is there an easy way to do this?

>>> first = {"a": 10, "b": 20}
>>> second = {"b": 5, "d": 7}
>>> for dom in second:
...     first.pop(dom, None)
...
20
>>> first, second
({'a': 10}, {'b': 5, 'd': 7})
>>>

Peter




More information about the Python-list mailing list