python 2.7 - Loop through dict key equals to list than put in new list -


i have rather large dictionary right set this:

largedict = {'journalname':{code: 2065},'journalname1':{code: 3055}} 

and on , on. , dictionary:

codes = {3055: 'medicine',3786: 'sciences'} 

and want loop through largedict, compare it's code value keys in codes. either add journalname key/value pairs match code different dictionary, or delete don't largedict.

new_dic = {journal_name : journal_body journal_name, journal_body in largedict.items() if journal_body["code"] in codes} 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -