I got a list of lists b and I want to check if they exist in list a which is also a list of lists.
I'm currently using the following method which is quite time-consuming. Is there a faster way?
b = [[5], [5, 3], [5, 3, 1], [5, 3, 1, 2]]
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]result = all(elem in b[0] for elem in a[0])
print(result)
result = all(elem in b[1] for elem in a[0])
print(result)
result = all(elem in b[2] for elem in a[0])
print(result)
result = all(elem in b[3] for elem in a[0])
print(result)result = all(elem in b[0] for elem in a[1])
print(result)
result = all(elem in b[1] for elem in a[1])
print(result)
result = all(elem in b[2] for elem in a[1])
print(result)
result = all(elem in b[3] for elem in a[1])
print(result) result = all(elem in b[0] for elem in a[2])
print(result)
result = all(elem in b[1] for elem in a[2])
print(result)
result = all(elem in b[2] for elem in a[2])
print(result)
result = all(elem in b[3] for elem in a[2])
print(result)
Output:
>>>False
>>>False
>>>False
>>>True
>>>False
>>>False
>>>False
>>>False
>>>False
>>>False
>>>False
>>>False