Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Help counting the total number of dictionaries inside a list thatcontain a specified key value
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Jon Bowlas, post: 3610330"] Hi All, I have the following list containing dictionaries and I would like to be able to count the total number of dictionaries I have that contain a certain value set for the 'level' key: [{'mod_title': u'Introduction to Human Anatomy', 'level': u'1', 'modcode': u'ANAT1003', 'deptleveltext': u'', 'deptlevelheader': u'Level 1 Courses', 'subj_code': u'AE'}, {'mod_title': u'Developmental Neurobiology', 'level': u'2', 'modcode': u'ANAT2008', 'deptleveltext': u'', 'deptlevelheader': u'Level 2 Courses', 'subj_code': u'AE'}, {'mod_title': u'Human Neuroanatomy', 'level': u'2', 'modcode': u'ANAT2010', 'deptleveltext': u'', 'deptlevelheader': u'Level 2 Courses', 'subj_code': u'AE'}, {'mod_title': u'Human Anatomy and Embryology', 'level': u'2', 'modcode': u'ANAT2050', 'deptleveltext': u'', 'deptlevelheader': u'Level 2 Courses', 'subj_code': u'AE'}, {'mod_title': u'Ethics of Fertility and Embryo Research', 'level': u'2', 'modcode': u'ANAT2099', 'deptleveltext': u'', 'deptlevelheader': u'Level 2 Courses', 'subj_code': u'AE'}, {'mod_title': u"Man's Place in Nature 1750-1900", 'level': u'23', 'modcode': u'HMED3001', 'deptleveltext': u'', 'deptlevelheader': u'Level 2/3 Courses', 'subj_code': u'AE'}, {'mod_title': u'Medicine, Disease and Society, Antiquity to Renaissance ', 'level': u'23', 'modcode': u'HMED3003', 'deptleveltext': u'', 'deptlevelheader': u'Level 2/3 Courses', 'subj_code': u'AE'}, {'mod_title': u'Madness and Society', 'level': u'23', 'modcode': u'HMED3004', 'deptleveltext': u'', 'deptlevelheader': u'Level 2/3 Courses', 'subj_code': u'AE'}] 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. Cheers Jon [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Help counting the total number of dictionaries inside a list thatcontain a specified key value
Top