Example of how to check if a word is in a list of words and sentences in python
Table of contents
Check if a word is in a list of words and sentences
Let's consider the followinf list:
mylist = ['hello', 'hola', 'hi, how are you today ?']
to check for example if the word 'today' is in the list a solution is to do
myword = 'today'
any(myword in w for w in mylist)
returns
True
ANother example:
myword = 'bonjour'
any(myword in w for w in mylist)
returns
False
References
- any | Python Doc
- Check if a Python list item contains a string inside another string | stackoverflow
- python: check if a line has one of the strings in a list [duplicate] | stackoverflow
- Check if multiple strings exist in another string | stackoverflow