I have a list of dictionaries in the following format
name_list = [{"id":1, "name": "john emmanuel"},
{"id":2, "name": "Nick Edison"},
{"id":3, "name": "Sor"}]
and a list of strings
string_list = ['i am happy',
'what is john emmanuel doing',
'how is nick taking care of everything',
'the category is sorrow']
I am trying to get the list of dictionary if the entire name in dictionary matches with that in the list of strings.
I tried this way:
name_found = []
for name in name_list:
if name["name"].lower() in ' '.join(string_list):
name_found.append(name)
Obtained Output
[{'id': 1, 'name': 'john emmanuel'}, {'id': 3, 'name': 'Sor'}]
Expected Output
[{'id': 1, 'name': 'john emmanuel'}]