fork(1) download
  1. def contains_words(text, words_list):
  2. for word in words_list:
  3. if text.find(word) != -1:
  4. return True
  5. return False
  6.  
  7. some_text = ['some text','another text','one more']
  8. whitelist = ['another','more']
  9. blacklist = ['some','else']
  10.  
  11. for text in some_text:
  12. if contains_words(text, whitelist) and not contains_words(text, blacklist):
  13. print("Found")
  14. else:
  15. print("Not found")
Success #stdin #stdout 0.02s 8736KB
stdin
Standard input is empty
stdout
Not found
Found
Found