check if elements from an array are in a string

Chester’s comment have it all.

But if you’d like a more readable version, something like that might help :

def include(lst = ['12','13','14'], search_string = '123456789'):
  for e in lst:
    if e in search_string:
      print(f'found {e}')
      return True
  return False

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top