How can I check if a list exists as a value in a dictionary which is a member of a list (list of dictionaries)?
totalList = ([{'score': 1, 'item': ['text1', 'text2']},
{'score': 2, 'item': ['text3', 'text4']},
{'score': 3, 'item': ['text5', 'text6']}])
redList = ['text1', 'text2']
A one-liner such as this (though this one doesn't work for obvious reasons). I want to avoid loops.
if redList in totalList:
print("True")
Context:
redlists = a list of lists
totalList = []
for redlist in redlists:
if redlist not in totalList:
totalList.append(dictionary_item))
Example ditcionary_item
= {'score': 1, 'item': ['text1', 'text2']}
Note: Total list keeps growing because every time redList is not in the totalList, I add a new dictionary to the toalList based on predefined criteria.