-1

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!

Nev
  • 1
  • 3
  • Could you please be more specific about what you need, do you just need a yes/no answer for example? And what have you tried already? – Jasmijn May 16 '22 at 12:24

1 Answers1

2

Python knows well how to compare dictionaries.

What about using a simple:

target in list_of_dict

output: True

mozway
  • 194,879
  • 13
  • 39
  • 75