I'm trying to develop a little script in Python but I've never used this language.
I have a structure that is something like this:
dict = [
{ "id" : 1,
"people" : [ { "name" : "Sarah",
"surename" : "something"
},
{ "name" : "Luke",
"surename" : "something"
},
{ "name" : "Chris",
"surename" : "something"
}
]
},
{ "id" : 2,
"people" : [ { "name" : "Jhon",
"surename" : "something"
},
{ "name" : "Luke",
"surename" : "something"
},
{ "name" : "Ronald",
"surename" : "something"
}
]
}
]
and I have another list of values, such as name_list = ["Sarah", "Luke"].
I need to find all the IDs of the structure such that all the names in the name_list are present inside the list of dictionaries people.
I've tried something like this but this does not work.
for person in dict:
if all(name_list in p["name"] for p in person["people"]):
# Do something with person["id"]
It is important to me to find all the IDs of the list of dictionaries that contains all the names the name_list.