Sometimes, we want to check if a word is in a string with Python.
In this article, we’ll look at how to check if a word is in a string with Python.
How to check if a word is in a string with Python?
To check if a word is in a string with Python, we can use the in operator.
For instance, we write:
if 'seek' in 'those who seek shall find':
print('Success!')
to check if 'seek' is included in 'those who seek shall find'.
Since this is True, 'Success!' is printed.
Conclusion
To check if a word is in a string with Python, we can use the in operator.