'how to compare a nested dictionary with list of nested dictionary in python

how to check target dictionary is present in list of nested dictionaries. only particular key details and books and their values needs to be checked.

target = {'details' : [{'name':'Ron','description':{'grade':'seven','section':'A'},'level':1}],
'Books':{'type':'Horror','id':101},
'version_id':{'version':10,'enable':true},
Total_marks':700}

list_of_dict = [
{'details' : [{'name':'jeff','description':{'grade':'six','section':'B'},'level':1}],
'Books':{'type':'Fiction','id':101},
'version_id':{'version':11,'enable':true},
Total_marks':900},

{'details' : [{'name':'Ron','description':{'grade':'seven','section':'A'},'level':1}],
'Books':{'type':'Horror','id':101},
'version_id':{'version':12,'enable':true},
Total_marks':700}]

Any help is greatly appreciated!



Solution 1:[1]

Python knows well how to compare dictionaries.

What about using a simple:

target in list_of_dict

output: True

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mozway