For this purpose you can use intersection sets .
def check_common_element(listA, listB, listC): common_elements = set.intersection(set(listA), set(listB), set(listC)) if common_elements: return True else: return False
As @ Reti43 suggested, you can do return bool(common_elements) instead of if-else as the best option for the reasons described in the comments below. In this case, the modified function will look like this:
def check_common_element(listA, listB, listC): common_elements = set.intersection(set(listA), set(listB), set(listC)) return bool(common_elements)
source share