Check if a word is present in a sentence | Function that returns true if the word is found ; To convert the word in uppercase ; To convert the complete sentence in uppercase ; To break the sentence in words ; To store the individual words of the sentence ; Compare the current word with the word to be searched ; Driver code
def isWordPresent ( sentence , word ) : NEW_LINE INDENT word = word . upper ( ) NEW_LINE sentence = sentence . upper ( ) NEW_LINE s = sentence . split ( ) ; NEW_LINE for temp in s : NEW_LINE INDENT if ( temp == word ) : NEW_LINE INDENT return True ; NEW_LINE DEDENT DEDENT return False ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT s = " Geeks ▁ for ▁ Geeks " ; NEW_LINE word = " geeks " ; NEW_LINE if ( isWordPresent ( s , word ) ) : NEW_LINE INDENT print ( " Yes " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) ; NEW_LINE DEDENT DEDENT