Files
30-seconds-of-code/snippets/includes_any.md
Angelos Chalaris 26772c3ee2 Move snippets in the correct folder
Related #188
2020-03-15 12:54:08 +02:00

501 B

title, tags
title tags
includes_any list,intermediate

Returns True if any element in values is included in lst, False otherwise.

Check if any value in values is contained in lst using a for loop, returning True if any one value is found, False otherwise.

def includes_any(lst, values):
  for v in values:
    if v in lst:
      return True
  return False
includes_any([1, 2, 3, 4], [2, 9]) # True
includes_any([1, 2, 3, 4], [8, 9]) # False