Help counting the total number of dictionaries inside a list that contain a specified key value

Christian Heimes lists at cheimes.de
Tue Aug 12 13:15:05 CEST 2008


Jon Bowlas wrote:
> For example I'd like to kow how many dictionaries there are with a
> level 1, 2 , 23 & 3 etc. How would one go about achieveing this?
> 
> Hope someone can help.

sum(u'Level 2 Courses' in dct for dct in yourlist)

Christian




More information about the Python-list mailing list