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

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -