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
Post a Comment