Thank you
Thank you
d1 = {'A': ['B', 'C'], 'B': ['A', 'C'], 'C': ['A', 'B'], 'D': ['B', 'C']}
To test full equality
d1['A']==d1['D']
True
d1['A']==d1['B']
False
Or specifically for your question, looking for elements of A
that are in C
.
equals = []
for e in d1['A']:
if e in d1['C']:
equals.append(e)
print (equals)
['B']
Or more pythonically in just one line with list comprehension
equals = [equal for equal in d1['A'] if equal in d1['C']]
print (equals)
['B']