I have a huge string like:
The Dormouse's story. Once upon a time there were three little sisters; and their names were Elsie, Lacie and Tillie; and they lived at the bottom of a well....badword...
and I have a list of around 400 bad words:
bad_words = ["badword", "badword1", ....]
what is the most efficient way to check if text contains a bad word from badwords list?
I could loop over both text and list like:
for word in huge_string:
for bw in bad_words_list:
if bw in word:
# print "bad word is inside text"...
but this seems to me to be from 90's..
Update: bad words are single words.
set intersection?anybadwordsare found insideinputstring? Or do you want to know which specifics are found?