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!
Python knows well how to compare dictionaries.
What about using a simple:
target in list_of_dict
output: True
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.