I have followed some examples on here for doing exactly what I am asking but I am not quite sure what I am doing wrong.
Basically, I want to find out if a given string contains any words from a list of words.
st = "hello this is a string"
ar = ['lo', 'str']
if any(e in st for e in ar):
print(True)
else:
print(False)
However I am getting True for this input. And similarly, when trying with some matching words I am getting False. Every source I have checked says to use the any in the way shown above to do what i desire. I just can't seem to get the hang of it. Any help would be appreciated!