0

I have an array called arr and need to check whether several values are in that array

if (val1 in arr) and (val2 in arr) and (val3 in arr) ... etc :
     return True

this way of doing it is obviously quite tedious. I would like to put my values into an array arr2 and use this to check if there are any matches, something like:

if matches(arr2, arr):
   return True

I have tried using

if arr2 in arr:
   return True

but this checks whether a arr2 is in arr, and since arr is just an array of values and does not contain any arrays, this is not going to work

Karl Knechtel
  • 56,349
  • 8
  • 83
  • 124
frog_prog
  • 39
  • 3
  • 1
    Welcome to Stack Overflow. "I would like to put my values into an array arr2 and use this to check if there are any matches" Good instinct. See the linked duplicate - you want to check whether `all` of the `arr2` elements are matches. Incidentally: we don't call them "arrays" in Python. – Karl Knechtel Jul 12 '21 at 09:12

0 Answers0