How to check if a string contains a word in Python

A string contains a word if the word occurs at least once in the string. For example, the string “a word string” contains the words “a”, “word”, and “string”.

Solution for How to check if a string contains a word in Python : You can use the in keyword to check if a word is in a string Use the in keyword to check if a word occurs in a string with the following syntax: a_word in a_string. This returns a boolean indicating whether a_word is found in a_string.


how-to-check-if-a-string-contains-a-word-in-python