For example, a = "abcdefg", b = "krtol", they have no intersection, c = "hflsfjg", then a and c have interoperational interaction.What is the easiest way to verify this? just need True or False result
def hasIntersection(a, b): return not set(a).isdisjoint(b)
You can use the built-in set class:
set
a = set("abcdefg") b = set("krtol") c = set("hflsfjg") if a.intersection(b): # or simply a & b pass