For example I want the out put here to be true because 1 is in the second list
[1,2,3] in ['a', 'b', 'c', 1]
I want like if any object from the first list is in the second list then return true
For example I want the out put here to be true because 1 is in the second list
[1,2,3] in ['a', 'b', 'c', 1]
I want like if any object from the first list is in the second list then return true
You can use any
(which outputs True
if any element in a list is True
) with a generator expression:
any(i in ['a', 'b', 'c', 1] for i in [1,2,3])