any function and list comprehension
def containsAtLeastOneCommonElement(data1, data2):
return any(i in data1 for i in data2)
result = containsAtLeastOneCommonElement([1, 6, 9], [5, 9, 12])
print(result) # True
result = containsAtLeastOneCommonElement([2, 4, 8], [5, 9, 12])
print(result) # False
Leave a Comment
Cancel reply