As @Adirio said in a comment, you can simply use the built-in function isdisjoint (available from version 2.6):
def myfunc(a,b):
return not a.isdisjoint(b)
I'm assuming you want to return False
when the intersection between a
and b
is empty, otherwise just remove the not
.