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

Amy G amy-g-art at cox.net
Mon Nov 24 17:43:18 EST 2003


Not sure that I actually have two dictionaries.  I am setting

domains_black = filter_domains2(domain_histogram, threshold)

I thought this would return a dictionary, but apparently it is a list.
How do I perform this operation on the dictionary?

I am going to have to think of some way to thank you for all of your help.


"Peter Otten" <__peter__ at web.de> wrote in message
news:bpu15f$k12$07$1 at news.t-online.com...
> 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