"Mark Devine" <[EMAIL PROTECTED]> writes:

> Sorry for not putting a subject in the last e-mail. The function lower suited 
> my case exactly. Here however is my main problem:
> Given that my new list is :
> [class-map match-all cmap1', 'match ip any', 'class-map match-any cmap2', 
> 'match any', 'policy-map policy1', 'class cmap1', 'policy-map policy2', 
> 'service-policy policy1', 'class cmap2']
>
> Each element in my new list could appear in any order together within another 
> larger list (list1) and I want to count how many matches occur. For example 
> the larger list could have an element 'class-map cmap2 (match any)' and I 
> want to match that but if only 'class-map match-any' or 'class-map cmap2' 
> appears I don't want it to match. 
>
> Can anybody help?
> Is my problem clearly stated?

Yes. Here's how to use the count method of a list to do it.

[(list1.count(element), element) for element in small]

is one way, but the dictionary method posted by Steve Holden will be
faster.

        <mike
-- 
Mike Meyer <[EMAIL PROTECTED]>                  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to