>>> l1 = [1,2,3]
>>> l2 = [1,2]
>>> assert all(any(x in l1 for x in l2))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'bool' object is not iterable
I want to check whether l2 is included in l1.
>Solution :
Just call all(), not any().
assert(all(x in l1 for x in l2))
You can also use set operations:
assert(set(l2) <= set(l1))