Reputation: 311
I have first list:
x = ["abc", "cde", .... "sadlfj"]
and the second list.
y = ["ABC", "DRF", .... "CXV"]
I need to check the following condition:
if any member of list "x" is in the list "y", then TRUE.
How to write this condition check without iteration?
Thank you
Upvotes: 0
Views: 40
Reputation:
Try sets, since you ask for the condition, not the actual elements in common:
x = [...]
y = [...]
if not set(x).isdisjoint(set(y)):
# they have something in common
Upvotes: 3