one-liner to check if at least one item in list exists in another list? [duplicate]

Python 2.6 and above:

def func(a, b):
  return not set(a).isdisjoint(b)

For 2.4 or 2.5:

def func(a, b):
  return len(set(a).intersection(b)) != 0

For 2.3 and below:

sudo apt-get update
sudo apt-get upgrade

😉

Leave a Comment