def list_grep(list, pattern):
 compiled = re.compile(pattern)
 for line in list:
  match = compiled.search(line)
  if match:
   return 1
 return 0

def list_grep ( list , pattern ) : compiled = re . compile ( pattern ) for line in list : match = compiled . search ( line ) if match : return 1 return 0
true if any item in list matches the specified pattern .