How to check if any two items of a list are within another list?
I am trying work out how to test if certain combinations of words appear within a list. For example:
l1 = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
if all(['A', 'C', 'D']) or all(['A', 'D']) or all(['C', 'D'])in l1:
print('Violation')
The idea is to determine if either (or both) A
and C
exist together with D
.
I have tried the code above, but I am always getting a violation as I assume it is only testing if a single item for any of the check lists are within L1
?